• Resolved Ramanan

    (@superpoincare)


    Hi Frank,

    As per loadCSS, the javascript can be loaded in head. All browsers except IE versions below 9 won’t block render. So the author recommends this.

    <link rel="preload" href="path/to/mystylesheet.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
    <noscript><link rel="stylesheet" href="path/to/mystylesheet.css"></noscript>
    <script>
    /*! loadCSS rel=preload polyfill. [c]2017 Filament Group, Inc. MIT License */
    (function(){ ... }());
    </script>

    Is there a filter which will move the javascript in the head?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Afraid not, but I’ll add a filter in AO 2.5.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Thread Starter Ramanan

    (@superpoincare)

    Oh great. Will try!

    Thread Starter Ramanan

    (@superpoincare)

    Tried

    add_filter( 'autoptimize_css_preload_polyfill_injectat', function() {
    	return array( '</head>', 'before' );
    } );

    and works!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    perfect ??

    there’s quite a number of other changes (fixes, improvements and new functionality) in there, so feel free to have a look around and report any issue you might find!

    Thread Starter Ramanan

    (@superpoincare)

    Yeah sure, will try to find.

    Thread Starter Ramanan

    (@superpoincare)

    Frank,

    Have observed this. In stable release itself. If one chooses to not concatenate css files, AO adds the query args from wp_enqueue_style even though the minified filename with the hash itself acts as a cache buster.

    Have you kept it for some reason?

    Sometimes themes just update without styles changing (to add other features). So the only difference in the style.css is the version in the header. The minified output won’t change. So having a query string unnecessarily busts cache.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Have you kept it for some reason?

    yes, because else there’s an overlap with “remove query strings” on the “extra” tab. now people who want to keep querystrings can, those who don’t simply have to tick that “extra”-option ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘loadCSS in head?’ is closed to new replies.