Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Responsive design and PageSpeed Insights Reply To: Responsive design and PageSpeed Insights

#238269
Shikkediel
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>