How To Fix Render Blocking CSS In Above The Fold Content Referencing CSS files with link[rel=stylesheet] will cause most browsers to delay page rendering while the stylesheet loads. This is desira...
2017-12-24T16:01:28Z

How To Fix Render Blocking CSS In Above The Fold Content

Referencing CSS files with link[rel=stylesheet] will cause most browsers to delay page rendering while the stylesheet loads. This is desirable in many cases, but when loading stylesheets that are not critical to the initial rendering of a page, loadCSS (and upcoming web standards mentioned below) allows you to load stylesheets, so they don’t block page rendering.

render blocking CSS in above the fold content

How to identify render-blocking render-blocking JavaScript and CSS


You need to know what your page is loading. There are several ways to do this. I suggest you look at what your page is loading with our pagespeed tool to get an overview of the issues your page or theme faces. To get the specific files that are currently blocking rendering you should use the Google pagespeed insights tool. This tool will tell you the exact files that are blocking a particular page.

Also Read :-

How To Fix Render Blocking CSS In Above The Fold Content


Just simply add your External stylesheets (read those included via link tags) are render-blocking into a noscript tag.

Example:-

If Your Link
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>

Just use below code

Method 1 :-

<noscript id="deferred-styles">
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
</noscript>
    <script>
      var loadDeferredStyles = function() {
        var addStylesNode = document.getElementById("deferred-styles");
        var replacement = document.createElement("div");
        replacement.innerHTML = addStylesNode.textContent;
        document.body.appendChild(replacement)
        addStylesNode.parentElement.removeChild(addStylesNode);
      };
      var raf = requestAnimationFrame || mozRequestAnimationFrame ||
          webkitRequestAnimationFrame || msRequestAnimationFrame;
      if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); });
      else window.addEventListener('load', loadDeferredStyles);
    </script>

Method 2 :-

<link as='style' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css' onload='this.rel=&#39;stylesheet&#39;' rel='preload'/>
<noscript><link href='https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css' rel='stylesheet'/></noscript>

Method 3 :-

<script type='text/javascript'>
//<![CDATA[
function loadCSS(e, t, n) { "use strict"; var i = window.document.createElement("link"); var o = t || window.document.getElementsByTagName("script")[0]; i.rel = "stylesheet"; i.href = e; i.media = "only x"; o.parentNode.insertBefore(i, o); setTimeout(function () { i.media = n || "all" }) }
loadCSS("https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css");
//]]>
</script>

So this was our guide on How To Fix Render Blocking CSS In Above The Fold Content, I hope the methods given above helped you.

Keywords:- load a CSS file asynchronously, Eliminate render-blocking CSS in above-the-fold content, Defer loading CSS.
Share it:

Blogger

Blogging

How To

Troubleshooting

Tumblr

Tutorial

WordPress

Post A Comment:

0 comments: