Home › Forums › CSS › Responsive design and PageSpeed Insights › Reply To: Responsive design and PageSpeed Insights
February 22, 2016 at 4:36 am
#238269
Participant
Google’s got it’s own recommendation there. :-)
<body>
...
<script>
var cb = function() {
var l = document.createElement('link');
l.rel = 'stylesheet';
l.href = 'mobile.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>
As far as I’ve seen, it only contributes 2 points though.
What Google doesn’t say – best to create a fallback. This is possible with HTML5 :
<head>
<noscript><link href="mobile.css" ... ></noscript>
</head>