Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #622588

    Hi,
    How can I improve pagespeed insight, and move style.css file to footer (tried to use scripts to footer, but it dont help) or import code from it to index?
    Like this code:

    <script>
        if (window.XMLHttpRequest) {
          xhr = new XMLHttpRequest();    
        } else {
          xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xhr.open("GET",'/stl/style.css',false);
        xhr.send();
        var lazyStyle = document.createElement('style');
        lazyStyle.innerHTML = xhr.responseText;
        document.head.appendChild(lazyStyle);
      </script>
    • This topic was modified 8 years, 8 months ago by mdxclr.
    #624456

    Hey mdxclr,

    loading css in the footer is nothing that is not a valid way to load styles according to the W3C so there is really no easy way to do this. And even if you do so it might not really help your site and just satisfy a general guideline.

    Just read the second response from Thomas here: https://groups.google.com/forum/#!topic/pagespeed-insights-discuss/uzOYa_lrepw

    And in fact, this is not a real issue. Your pages may load fast as lightning without this rule fulfilled or slowly like snails fulfilling it. Remember the hints at Page Speed Insights are just hints and suggestions what you could do to improve your users’ experience. PSI does not measure the real loading times over different connections and with different devices (we all know some of them are a pain – both), but only technical preconditions.

    In short: I wouldnt worry about the rule and not waste to much time trying to satisfy it…

    Best regards,
    Kriesi

    #624466

    Hey!

    We do not recommend moving styles to the bottom doing so will cause a flash of unstyled elements. The styles are anyways minified and it should load fast.

    However to improve the page speed you can move some js files to the footer using a wordpress plugin like https://wordpress.org/plugins/scripts-to-footerphp/

    Cheers!
    Vinay

    • This reply was modified 8 years, 8 months ago by Vinay.
    #624564

    Used autoptimize and scripts to footer and get 95%.
    Thank you.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Load CSS in footer’ is closed to new replies.