-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
We want to load our no-essential css at the end. We can use a script like the next one for the task:
<html>
<head>
<style>
.blue{color:blue;}
</style>
</head>
<body>
<div class="blue">
Hello, world!
</div>
<script>
var cb = function() {
var l = document.createElement('link'); l.rel = 'stylesheet';
l.href = 'small.css'; //loads small.css
var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(cb);
else window.addEventListener('load', cb);
</script>
</body>
</html>Futher reading: https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery
Reactions are currently unavailable