{"id":89438,"date":"2023-05-22T13:24:30","date_gmt":"2023-05-22T17:24:30","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=89438"},"modified":"2024-11-12T08:37:11","modified_gmt":"2024-11-12T13:37:11","slug":"render-blocking-css","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/render-blocking-css\/","title":{"rendered":"Eliminate Render-Blocking CSS with W3 Total Cache Pro"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><div class=\"boldgrid-section\">\r\n<div class=\"container\">\r\n<div class=\"row\">\r\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\r\n<p>There are two major things that must load before your website can be &ldquo;rendered,&rdquo; the Document Object Model (DOM) and the CSSOM (Cascading Style Sheet Object Model).<\/p>\r\n<p>The DOM contains all of the markups for your website, and the CSSOM contains all of the styling to display it correctly.<\/p>\r\n<p>In WordPress, most CSS files, or stylesheets, are loaded as separate files as enqueued by your theme, plugins, and other site assets, and this leads to numerous network requests that are considered &ldquo;render-blocking.&rdquo; In this guide, you&rsquo;ll learn how to eliminate render-blocking CSS by moving it to the HTML body with W3 Total Cache Pro.<\/p>\r\n\t  \n\t<div class=\"bg-proof bg-shadow\">\n\t\t<div>\n\t\t\t<span class=\"bg-green-circle\">17.5<\/span>\n\t\t\t<span class=\"bg-green-description\">Points<\/span>\n\t\t<\/div>\n\t\t<div>\n\t\t\t<p>In a recent test, Eliminating render blocking CSS improved our <strong>PageSpeed Score <\/strong>by over 17 points on mobile devices! <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/pagespeed-tests\/eliminate-render-blocking-css\/\">Check out the test results<\/a> to see how we accomplished this!<\/p>\n\t\t\t<p>\n\t\t\t\t<a class=\"button-primary\" href=\"https:\/\/www.w3-edge.com\/checkout-standalone-1\/?utm_source=boldgrid&amp;utm_medium=support-on-page&amp;utm_campaign=BoldGrid\" style=\"background: #21759b;padding: 6px 10px;\">Upgrade to W3 Total Cache Pro<\/a> and improve your PageSpeed Scores today!\n\t\t  \t<\/p>\n\t\t\t<div class=\"bg-proof-meta\">\n\t\t\t\t<div><strong>Audit:<\/strong> Google PageSpeed Score<\/div>\n\t\t\t\t<div><strong>Before:<\/strong> 53.75<\/div>\n\t\t\t\t<div><strong>After:<\/strong> 71<\/div>\n\t\t\t<\/div>\n\t  \t<\/div>\n\t<\/div>\n\t  \n    \r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n\r\n\r\n<div class=\"boldgrid-section\" style=\"margin-top: 60px;\">\r\n<div class=\"container w3tc-radius\" style=\"border-width: 0px; background-image: url('https:\/\/www.boldgrid.com\/wp-content\/uploads\/2023\/07\/upsell-darker-alt.png'); background-size: cover; background-position: 50% 5%;\" data-image-url=\"https:\/\/www.boldgrid.com\/wp-content\/uploads\/2023\/07\/upsell-darker-alt.png\">\r\n<div class=\"row upsell-column\" style=\"padding-top: 2em; padding-bottom: 2em; color: #ffffff;\">\r\n<div class=\"col-lg-1 col-md-1 col-sm-12 col-xs-12 hidden-sm\">&nbsp;<\/div>\r\n<div class=\"col-lg-5 col-md-6 col-xs-12 col-sm-7\">\r\n<p class=\"h3\" style=\"color: #ffffff; line-height: 40px; margin-top: 0;\"><strong>Speed Up Your WordPress Website.<\/strong><\/p>\r\n<p class=\"h4\" style=\"color: #ffffff;\">A Difference of Just 100ms in Page Load Speeds Can Cause a Visitor to Prefer Your Competitor&rsquo;s Website.<\/p>\r\n<\/div>\r\n<div class=\"col-lg-6 col-md-5 col-sm-5 col-xs-12 text-center align-column-center\">\r\n<p class=\"\" style=\"border-width: 0px;\"><a class=\"button-w3tc-white\" style=\"border: 2px solid #30BEC4; font-size: 18px; padding: 15px 30px;\" href=\"https:\/\/www.boldgrid.com\/w3-total-cache\/#pricing\">View Plans<\/a><\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n<div class=\"boldgrid-section\">\r\n<div class=\"container\">\r\n<div class=\"row\">\r\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\r\n<h2 class=\"wp-block-heading\" id=\"why-do-i-need-to-eliminate-render-blocking-css\">Why Do I Need to Eliminate Render-Blocking CSS?<\/h2>\r\n<p>If a site&rsquo;s markup is loaded without CSS, it can cause a &ldquo;Flash of Unstyled Content,&rdquo; (FOUC) which will contribute to the Cumulative Layout Shift (CLS) Core Web Vital metric. It may also lead to longer First Contentful Paint (FCP) metrics, and overall cause a poorer user experience and Core Web Vitals score.<\/p>\r\n<p>Let&rsquo;s take a look at what render-blocking CSS may cause your website to look like on a slow web connection. Here are two images of the WordPress Dashboard, one without CSS, and one with CSS:<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89490 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-1.png\" alt=\"wordpress dashboard loaded without css styles applied\" width=\"512\" height=\"346\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-1.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-1-300x203.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89491 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-2.png\" alt=\"wordpress dashboard with css styles loaded correctly.\" width=\"512\" height=\"352\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-2.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-2-300x206.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\r\n<p>On a slower connection, a user might briefly see the first image, and only see the styled content after the stylesheets load.<\/p>\r\n<h2 class=\"wp-block-heading\" id=\"what-is-moving-to-the-http-body\">What is &ldquo;Moving to the HTTP Body?&rdquo;<\/h2>\r\n<p>When you use W3 Total Cache Pro to eliminate render-blocking CSS, your stylesheets are first minified, then combined, and finally inserted into the top of the DOM as an inline style, rather than a separate network request.<\/p>\r\n<p>This means that your visitors will receive all of the necessary styles at the same time that they receive the rest of your site&rsquo;s markup, and therefore eliminate any Layout Shift caused by CSS and further delays in rendering the First Contentful Paint.<\/p>\r\n\t  \n\t<div class=\"bg-proof bg-shadow\">\n\t\t<div>\n\t\t\t<span class=\"bg-green-circle\">-94.86%<\/span>\n\t\t\t<span class=\"bg-green-description\">Potential Savings<br>from Render Blocking<br>Resources<\/span>\n\t\t<\/div>\n\t\t<div>\n\t\t\t<p>In one of our newest PageSpeed Experiments, moving our CSS to the HTTP body reduced our <strong>Potential Savings From Render-Blocking Resources <\/strong>by over 94% loading nearly 2 seconds faster on mobile devices! <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/pagespeed-tests\/eliminate-render-blocking-css\/\">Check out our test results<\/a> to see how we did it!<\/p>\n\t\t\t<p>\n\t\t\t\t<a class=\"button-primary\" href=\"https:\/\/www.w3-edge.com\/checkout-standalone-1\/?utm_source=boldgrid&amp;utm_medium=support-on-page&amp;utm_campaign=BoldGrid\" style=\"background: #21759b;padding: 6px 10px;\">Upgrade to W3 Total Cache Pro<\/a> and improve your PageSpeed Scores today!\n\t\t  \t<\/p>\n\t\t\t<div class=\"bg-proof-meta\">\n\t\t\t\t<div><strong>Audit:<\/strong> Potential Savings From Render-Blocking Resources<\/div>\n\t\t\t\t<div><strong>Before:<\/strong> 2432.5 ms<\/div>\n\t\t\t\t<div><strong>After:<\/strong> 125 ms<\/div>\n\t\t\t<\/div>\n\t  \t<\/div>\n\t<\/div>\n\t  \n    \r\n<h2 class=\"wp-block-heading\" id=\"how-do-i-eliminate-render-blocking-css-with-w3-total-cache-pro\">How do I Eliminate Render-Blocking CSS with W3 Total Cache Pro?<\/h2>\r\n<ol>\r\n<li>Navigate to the <strong>Performance &mdash; General Settings<\/strong> menu and enable Minify. Try Automatic mode first.<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89492 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-3.png\" alt=\"minify control enabled in the w3 total cache general settings\" width=\"512\" height=\"245\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-3.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-3-300x144.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/li>\r\n\r\n\r\n\r\n<li>Navigate to the <strong>Minify<\/strong> settings menu, and scroll down to the <strong>CSS <\/strong>section. Ensure that minify is enabled, and select <strong>Eliminate render-blocking CSS by moving it to HTTP body<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89493 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-4.png\" alt=\"css minification enabled along with the eliminate render blocking css control under the minify controls section.\" width=\"512\" height=\"195\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-4.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-4-300x114.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/strong><strong><br><\/strong><\/li>\r\n<\/ol>\r\n<p>That&rsquo;s it! Your CSS stylesheets will now be automatically minified and moved to the top of your main DOM (HTTP Body).<\/p>\r\n<h2 class=\"wp-block-heading\" id=\"how-do-i-tell-if-its-working\">How Do I Tell If It&rsquo;s Working?<\/h2>\r\n<p>Most of the time, you&rsquo;ll be able to tell simply by running Google&rsquo;s PageSpeed Insights tool, or by running the Lighthouse tool in your browser&rsquo;s developer tools. However, if you&rsquo;d like to check out how it works under the hood, follow these steps.<\/p>\r\n<ol>\r\n<li>First, disable the setting and purge all caches<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89494 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-5.png\" alt=\"eliminate render-blocking css control disabled. save settings and purge cache button highlighted.\" width=\"512\" height=\"285\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-5.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-5-300x167.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/li>\r\n\r\n\r\n\r\n<li>Load your site in an Incognito, or Private Browsing Window and open your browser&rsquo;s developer tools, and check out the <strong>Network<\/strong> tab. In Chrome, the shortcut for this is <strong>Ctrl-Shift-i<\/strong>. In Firefox, use <strong>Ctrl-Shift-e<\/strong>. For simplification, use the <strong>CSS<\/strong> filter to show only the relevant requests. Take note of the various minified CSS files you can see.<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89495 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-6.png\" alt=\"css filter selected under the network tab in the browser developer tools. only css files are listed.\" width=\"512\" height=\"412\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-6.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-6-300x241.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/li>\r\n\r\n\r\n\r\n<li>Go back to your Dashboard, and re-enable the option to eliminate render-blocking css in the <strong>Minify<\/strong> settings menu, then reload your site in the private browsing window. (Hint: delete the network requests history with the <strong>Clear<\/strong> button). Note that there are no longer any separate network requests for stylesheets.<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89496 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-7.png\" alt=\"css filter selected in the developer network tab. no css files are shown in the list.\" width=\"512\" height=\"365\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-7.png 512w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-7-300x214.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/li>\r\n\r\n\r\n\r\n<li>Switch over to the <strong>Elements <\/strong>tab of your developer tools, and note that all of your stylesheets have been minified and added to the &lt;head&gt; element of your DOM.<br><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89497 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-8.png\" alt=\"page source html view showing all of the css style files loaded in the website head section.\" width=\"507\" height=\"512\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-8.png 507w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-8-297x300.png 297w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/05\/render-blocking-css-8-150x150.png 150w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/a><\/li>\r\n<\/ol>\r\n<h2 class=\"wp-block-heading\" id=\"how-do-i-make-it-even-faster\">How Do I Make It Even Faster?<\/h2>\r\n<p>Eliminating render-blocking CSS via the automatic method will almost always improve your PageSpeed Insights score, but you may choose to optimize even further. The following steps will take some development skills, but you should feel encouraged to dive deeper to get even better results.<\/p>\r\n<h3 class=\"wp-block-heading\" id=\"what-types-of-stylesheets-are-actually-render-blocking\">What Types of Stylesheets Are Actually Render-Blocking?<\/h3>\r\n<p>Stylesheets are only considered <a href=\"https:\/\/web.dev\/critical-rendering-path-render-blocking-css\/\">Render-Blocking if they apply to <strong>All Media Types<\/strong><\/a>. By using Auto-Minify, you&rsquo;ll be minifying and combining <strong>all<\/strong> of your stylesheets into the HTTP Body. This may have a negative impact on sites with a lot of plugins, or complicated themes, because the DOM request filesize may become larger than ideal.<\/p>\r\n<p>Instead, you may choose to use <strong>Manual Minify<\/strong> mode to further optimize your CSS. Using manual, you can select the specific files to combine, minify, and move to the HTTP body.&nbsp;<\/p>\r\n<ol>\r\n<li>Examine your site&rsquo;s source HTML, and perform a CTRL-F search for all instances of the string<strong> rel=&ldquo;stylesheet&rdquo;<\/strong>.<\/li>\r\n\r\n\r\n\r\n<li>Using this search, locate any stylesheets that <strong>do not <\/strong>specify a <strong>media<\/strong> type, or use <strong>media=&ldquo;all&rdquo;<\/strong> . These are the stylesheets that are considered render-blocking.<\/li>\r\n\r\n\r\n\r\n<li>Navigate to the <strong>Minify<\/strong> settings menu, and add each stylesheet that applies to all media to the list of minified files.<\/li>\r\n\r\n\r\n\r\n<li>Save your settings, check that your site renders correctly, and perform a new PageSpeed Insights report to ensure that you didn&rsquo;t miss any render-blocking stylesheets.<\/li>\r\n<\/ol>\r\n\t  \n\t<div class=\"bg-proof bg-shadow\">\n\t\t<div>\n\t\t\t<span class=\"bg-green-circle\">-56.59%<\/span>\n\t\t\t<span class=\"bg-green-description\">LCP Score<\/span>\n\t\t<\/div>\n\t\t<div>\n\t\t\t<p>In one of our recent tests, Eliminating render blocking CSS improved our <strong>Largest Contentful Paint time <\/strong>by over 56% loading nearly 4 seconds faster on mobile devices! <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/pagespeed-tests\/eliminate-render-blocking-css\/\">Check out the results<\/a> to see how we did it!<\/p>\n\t\t\t<p>\n\t\t\t\t<a class=\"button-primary\" href=\"https:\/\/www.w3-edge.com\/checkout-standalone-1\/?utm_source=boldgrid&amp;utm_medium=support-on-page&amp;utm_campaign=BoldGrid\" style=\"background: #21759b;padding: 6px 10px;\">Upgrade to W3 Total Cache Pro<\/a> and improve your PageSpeed Scores today!\n\t\t  \t<\/p>\n\t\t\t<div class=\"bg-proof-meta\">\n\t\t\t\t<div><strong>Audit:<\/strong> Largest Contentful Paint<\/div>\n\t\t\t\t<div><strong>Before:<\/strong> 7s<\/div>\n\t\t\t\t<div><strong>After:<\/strong> 3.04s<\/div>\n\t\t\t<\/div>\n\t  \t<\/div>\n\t<\/div>\n\t  \n    \r\n<h2 id=\"faq\">FAQ<\/h2>\r\n<h3 id=\"what-are-resources\">What are resources?<\/h3>\r\n<p>In the context of web development, &ldquo;resources&rdquo; refer to the various components needed to load and display a web page properly. These include HTML, CSS, and JavaScript files, as well as images, videos, fonts, and other media or data files. Each resource is fetched from the server and processed by the browser to render the web page as intended by its design.<\/p>\r\n<h3 id=\"how-does-a-browser-render-a-web-page\">How does a browser &ldquo;render&rdquo; a web page?<\/h3>\r\n<p>The browser rendering process involves several detailed steps:<\/p>\r\n<ol>\r\n<li>\r\n<p><strong>Parsing HTML to Build the DOM<\/strong>: The browser reads the HTML code and creates the DOM (Document Object Model), a tree-like structure representing all page elements.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Creating the CSSOM<\/strong>: For every CSS style encountered (inline, embedded, or external), the browser constructs the CSS Object Model (CSSOM), detailing how elements should be styled.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Render Tree Construction<\/strong>: The browser combines the DOM and CSSOM to create the render tree, which includes only visible page elements and their styles.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Layout (Reflow)<\/strong>: The browser calculates the position and size of each element within the viewport, considering the current window size and the computed styles for each element.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Painting<\/strong>: The browser fills in pixels for the elements, applying text, colors, images, etc., according to the render tree.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Compositing<\/strong>: The browser draws elements onto the screen in the correct order, ensuring that elements that overlap are displayed properly.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>This complex process transforms the code into the visual and interactive experience users see on their screens.<\/p>\r\n<p>To learn more, we recommend starting out with <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Performance\/Critical_rendering_path\" target=\"_blank\" rel=\"noopener\">Critical rendering path<\/a>.<\/p>\r\n<h3 id=\"what-does-it-mean-when-an-html-document-has-been-fully-parsed\">What does it mean when an html document has been fully parsed?<\/h3>\r\n<p>When an HTML document has been fully parsed, it means that the browser has read through the entire HTML code, converting it into a structured, in-memory representation known as the Document Object Model (DOM).<\/p>\r\n<p>During this process, the browser identifies all the elements, attributes, and text within the HTML file, creating a tree-like structure that represents the hierarchy and organization of the webpage. This structured representation allows the browser to render the page visually and enables JavaScript to interact with the page&rsquo;s content through the DOM API.<\/p>\r\n<p>A fully parsed document is ready for further processing, including the execution of scripts that were deferred (using the <code>defer<\/code> attribute) until this point, ensuring they interact with a fully constructed DOM.<\/p>\r\n<h3 id=\"what-are-render-blocking-resources\">What are render-blocking resources?<\/h3>\r\n<p>&ldquo;Render-blocking resources&rdquo; refers to elements, typically CSS and JavaScript files, that must be loaded before a web page can be displayed to the user.<\/p>\r\n<p>These resources are considered &ldquo;blocking&rdquo; because browsers must pause the rendering of the page until these files are fully downloaded and processed. This can significantly delay the time it takes for a page to become visible and interactive, affecting user experience and potentially impacting a site&rsquo;s performance metrics and search engine rankings.<\/p>\r\n<h3 id=\"what-is-an-example-of-a-render-blocking-resource\">What is an example of a render-blocking resource?<\/h3>\r\n<p>A common example of a render-blocking resource is a CSS file linked in the HTML head. For instance, if a website&rsquo;s HTML includes a link to a stylesheet like:<\/p>\r\n<p><code>&lt;link href=\"styles.css\" rel=\"stylesheet\"&gt;<\/code><\/p>\r\n<p>&hellip; the browser must download and process this CSS file before it can render the page content. This means the site won&rsquo;t be visible to the user until &ldquo;styles.css&rdquo; is fully loaded, potentially delaying how quickly the page can be displayed.<\/p>\r\n<h3 id=\"are-only-scripts-and-styles-render-blocking\">Are only scripts and styles render blocking?<\/h3>\r\n<p>Other resources, like images or fonts, do not block HTML parsing but can affect the speed at which a page becomes visually complete. While images and fonts are critical for visual rendering, they are typically not considered render-blocking in the same sense as CSS and JavaScript because the browser can continue parsing and laying out the page while these resources are being loaded. The primary concern with render-blocking revolves around CSS and JavaScript, which must be processed before the page can render and become interactive.<\/p>\r\n<h3 id=\"what-is-the-opposite-of-render-blocking\">What is the opposite of render-blocking?<\/h3>\r\n<p>The opposite of &ldquo;render-blocking&rdquo; is often referred to as &ldquo;non-blocking&rdquo; or &ldquo;asynchronous&rdquo; loading. This approach involves loading resources such as JavaScript or CSS in a way that does not interfere with the initial rendering of the page. Techniques include using the async and defer attributes for scripts, which allow the browser to continue parsing and rendering the HTML while scripts are being downloaded in the background, thereby improving page load times and user experience.<\/p>\r\n<h3 id=\"how-can-css-and-styles-be-made-non-blocking\">How can css and styles be made non-blocking?<\/h3>\r\n<p>CSS and styles can be made non-blocking through several techniques:<\/p>\r\n<ol>\r\n<li>\r\n<p><strong>Use Media Queries<\/strong>: Specify media types or queries on <code>&lt;link&gt;<\/code> elements to load stylesheets conditionally, ensuring they are only loaded when needed. For example, print stylesheets don&rsquo;t need to block rendering of the page on screen.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Critical CSS<\/strong>: Inline the critical CSS directly in the HTML document. This is the minimal set of styles needed to render the above-the-fold content, allowing the page to display content quickly before additional styles are loaded.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Load CSS Asynchronously<\/strong>: Use JavaScript to load CSS files asynchronously. This can be done by dynamically creating a <code>&lt;link&gt;<\/code> element in the DOM via JavaScript or using libraries that facilitate asynchronous loading.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Use <code>rel=\"preload\"<\/code><\/strong>: Mark non-critical CSS files with <code>rel=\"preload\"<\/code> as a hint to the browser that these resources are important but do not need to block rendering. They can be downloaded asynchronously and applied once loaded.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>Implementing these strategies helps improve the rendering performance of web pages by reducing the impact of CSS files on the critical rendering path.<\/p>\r\n<h3 id=\"how-can-js-and-scripts-be-made-non-blocking\">How can JS and Scripts Be Made Non-Blocking?<\/h3>\r\n<p>JavaScript and scripts can be made non-blocking through several methods to improve page load times:<\/p>\r\n<ol>\r\n<li>\r\n<p><strong>Use the <code>async<\/code> Attribute<\/strong>: Adding <code>async<\/code> to a script tag (<code>&lt;script async src=\"...\"&gt;<\/code>) allows the script to be downloaded in the background. The browser can continue parsing and rendering the HTML page while the script is being fetched. The script will be executed as soon as it&rsquo;s downloaded, without waiting for the parsing to complete.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Use the <code>defer<\/code> Attribute<\/strong>: The <code>defer<\/code> attribute (<code>&lt;script defer src=\"...\"&gt;<\/code>) also allows the script to be downloaded asynchronously, but it guarantees that scripts execute in the order they appear in the document and only after the document has been fully parsed. This is particularly useful for scripts that rely on the entire DOM being available.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Dynamically Load Scripts<\/strong>: JavaScript can be used to dynamically load other scripts on demand. This involves creating <code>&lt;script&gt;<\/code> elements via JavaScript and appending them to the DOM, which allows for more control over when and how scripts are loaded and executed.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Move Scripts to the Bottom<\/strong>: Although less effective than <code>async<\/code> or <code>defer<\/code>, moving <code>&lt;script&gt;<\/code> tags to the bottom of the HTML body ensures that the browser can render the rest of the HTML page before it needs to load and execute the scripts. This can improve the time to first render, even though it&rsquo;s a more dated technique.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>Each of these methods can help minimize the performance impact of JavaScript, making web pages faster and more responsive.<\/p>\r\n<h3 id=\"what-is-the-difference-between-async-and-defer\">What is the difference between Async and Defer?<\/h3>\r\n<p>The async and defer attributes are used in &lt;script&gt; tags to control the loading and execution of JavaScript files without blocking the rendering of the page. Here&rsquo;s a more detailed comparison and examples of each:<\/p>\r\n<p><strong>async<\/strong><\/p>\r\n<ul>\r\n<li>When you add async to a script tag, the script is downloaded in the background while the browser continues to parse and render the HTML document.<\/li>\r\n<li>Scripts with async are executed as soon as they are downloaded, which means they might run in a different order from how they appear in the HTML. This can lead to problems if the scripts depend on each other.<\/li>\r\n<li>async is best used for scripts that do not depend on other scripts and do not modify the DOM immediately upon loading.<\/li>\r\n<\/ul>\r\n<p><strong>Example<\/strong>:<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<!-- \/wp:post-content -->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:list {\"ordered\":true} \/-->\r\n\r\n<!-- wp:heading \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading {\"level\":3} \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:list {\"ordered\":true} \/-->\r\n\r\n<!-- wp:heading -->\r\n<div><code>&lt;script async src=\"analytics.js\"&gt;&lt;\/script&gt;<\/code><\/div>\r\n<div class=\"boldgrid-section\">\r\n<div class=\"container\">\r\n<div class=\"row\">\r\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\r\n<p>This script can be loaded and executed asynchronously without affecting the page&rsquo;s initial rendering or depending on other scripts.<\/p>\r\n<p><strong>defer<\/strong><\/p>\r\n<ul>\r\n<li>Scripts with defer are also downloaded in the background, but they are executed only after the HTML document has been fully parsed.<\/li>\r\n<li>defer scripts are executed in the order they appear in the document, making them suitable for scripts that depend on each other or rely on the full HTML document being parsed.<\/li>\r\n<li>Use defer for scripts that need the entire DOM but should not block the page from rendering.<\/li>\r\n<\/ul>\r\n<p><strong>Example:<\/strong><\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<div><code>&lt;script defer src=\"app.js\"&gt;&lt;\/script&gt;<\/code><\/div>\r\n<div class=\"boldgrid-section\">\r\n<div class=\"container\">\r\n<div class=\"row\" style=\"padding-bottom: 21px;\">\r\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\r\n<p>This script will be executed after the HTML document is parsed, preserving execution order without blocking the initial page render.<\/p>\r\n<p><strong>Key Differences<\/strong><\/p>\r\n<ul>\r\n<li>Execution Order: async scripts execute as soon as they&rsquo;re downloaded, which could be out of order, while defer scripts maintain their order relative to each other and execute after the document is parsed.<\/li>\r\n<li>Use Cases: Use async for independent, non-DOM reliant scripts like analytics. Use defer for scripts that need the whole DOM or rely on the execution order.<\/li>\r\n<\/ul>\r\n<p>Choosing between async and defer depends on the specific needs of your scripts and how they interact with the rest of your page.<\/p>\r\n<h3 id=\"what-types-of-scripts-should-be-render-blocking\">What types of scripts should be render-blocking?<\/h3>\r\n<p>The goal is typically to avoid render-blocking scripts wherever possible to improve page load times and user experience. However, there are scenarios where scripts might be intentionally made render-blocking due to their critical importance to the page. Here are examples where scripts might be considered necessary to be render-blocking, though modern best practices often aim to minimize these cases:<\/p>\r\n<ol>\r\n<li>\r\n<p><strong>Critical Inline JavaScript<\/strong>: Scripts that are essential for rendering the initial view of the webpage and are too small or crucial to be deferred. This might include inline JavaScript within the HTML that initializes necessary layout or visual elements before anything else is processed.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Early-Stage Feature Detection<\/strong>: Scripts that perform feature detection for older browsers to conditionally load polyfills or alternate stylesheets. These need to run before the rest of the page to ensure compatibility.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Security or Compliance Scripts<\/strong>: Certain scripts related to security, compliance, or cookie consent that must run before any other content is loaded or interacted with by the user.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Web Fonts Loader<\/strong>: JavaScript-based font loaders that bring in custom fonts before the page renders to prevent a flash of unstyled text (FOUT). While not ideal, in some cases, these scripts are prioritized to ensure visual consistency from the moment the page starts loading.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Minimal, Early UI Setup<\/strong>: Scripts that set up a minimal user interface or critical path CSS before the rest of the page loads. This could be part of a strategy to enhance perceived performance, where a minimal layout is shown to the user as quickly as possible.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>While these examples can be situations where scripts are render-blocking by necessity or design choice, the overarching trend in web development is to find strategies that mitigate the need for render-blocking resources.<\/p>\r\n<h3 id=\"what-types-of-scripts-should-load-async\">What types of scripts should load async?<\/h3>\r\n<ol>\r\n<li>\r\n<p><strong>Analytics Scripts<\/strong>: Scripts for analytics platforms (like Google Analytics) are ideal candidates for <code>async<\/code> loading. They track user behavior and gather data without affecting the page&rsquo;s initial rendering or functionality. Since these scripts don&rsquo;t modify the DOM or depend on other scripts, they can be loaded in the background without impacting user experience.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Social Media Sharing Buttons<\/strong>: Many websites include social media sharing buttons that load external scripts (e.g., from Facebook or Twitter) to function. These scripts, often not critical to the primary content, can be loaded asynchronously to prevent them from blocking the page&rsquo;s main content and functionality from rendering promptly.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Ad Scripts<\/strong>: Advertising scripts that load ads onto a page are perfect for asynchronous loading. Ads are typically not essential to a webpage&rsquo;s main content, so loading these scripts asynchronously ensures that they do not slow down the access to the content that users came for.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Third-Party Widgets<\/strong>: Widgets from third-party services, such as weather updates, news tickers, or chatbots, should be loaded asynchronously. These elements offer supplementary information or features and should not delay the loading of the core content and functionality of the page.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<h3 id=\"what-types-of-scripts-should-load-with-defer\">What types of scripts should load with defer?<\/h3>\r\n<ol>\r\n<li>\r\n<p><strong>Main JavaScript Frameworks or Libraries<\/strong>: Scripts that contain essential frameworks or libraries (like jQuery, React, or Vue) that are used to build the page&rsquo;s structure and functionality should be loaded with <code>defer<\/code>. This ensures that the entire HTML document is parsed before these critical scripts are executed, maintaining script execution order without blocking the initial rendering.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Document Manipulation Scripts<\/strong>: Scripts that modify the DOM or initialize the UI, assuming they are not needed immediately as the page starts to load, are best loaded with <code>defer<\/code>. This ensures that the entire page is available for manipulation once the script runs, preventing errors that could occur if the script tries to modify elements not yet loaded.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Web Application Bootstrap Scripts<\/strong>: For single-page applications (SPAs) or any web application that initializes from a script, using <code>defer<\/code> ensures that the app&rsquo;s bootstrap code executes only after the HTML is fully parsed. This is crucial for applications that rely on a complete DOM for initialization.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Custom Analytics or Tracking Scripts<\/strong>: Unlike third-party analytics that can be loaded asynchronously, custom-built analytics or tracking scripts that depend on a fully loaded DOM or need to ensure accurate pageview hits after the page is fully loaded should use <code>defer<\/code>. This ensures the tracking code executes in the correct order and context.<\/p>\r\n<\/li>\r\n<li>\r\n<p><strong>Lazy-Loaded Component Scripts<\/strong>: If your site dynamically loads components based on user interaction but these components are not immediately necessary, you can initially load the scripts with <code>defer<\/code>. Once the page is fully loaded, these deferred scripts can then take care of loading additional components as needed, ensuring a smooth user experience without compromising initial load performance.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>Using <code>defer<\/code> for these types of scripts ensures that they are executed in the correct order and only after the HTML document has been fully parsed, facilitating a faster page load time while still enabling complex functionalities and interactions on the webpage.<\/p>\r\n<h3 id=\"can-css-use-async-or-defer\">Can CSS use Async or Defer?<\/h3>\r\n<p>No, the <code>async<\/code> and <code>defer<\/code> attributes are specifically for <code>&lt;script&gt;<\/code> tags in HTML and cannot be directly applied to CSS. CSS has its own mechanisms for non-blocking loading, such as using media queries, <code>rel=\"preload\"<\/code>, or inlining critical CSS directly into the HTML to avoid render-blocking. CSS inherently behaves differently from JavaScript in the loading and rendering process, requiring different strategies to optimize performance.<\/p>\r\n<h3 id=\"async-and-defer-vs-placement-of-scripts-in-the-head-and-body\">async and defer vs. placement of scripts in the head and body<\/h3>\r\n<p><strong>Historical Context &ndash; Traditional Placement of Scripts:<\/strong><\/p>\r\n<ul>\r\n<li><strong>In the Head<\/strong>: Initially, scripts were often placed in the <code>&lt;head&gt;<\/code> of HTML documents. This approach ensured that all JavaScript was loaded before the page&rsquo;s content, which could be important for scripts that needed to interact with or modify the DOM as soon as the page began to load. However, this method introduced render-blocking, where the browser would halt rendering until all scripts were downloaded and executed, leading to slower page load times.<\/li>\r\n<li><strong>At the End of the Body<\/strong>: To mitigate render-blocking issues, developers started moving scripts to the bottom of the <code>&lt;body&gt;<\/code>. This practice allowed the browser to render the HTML content first, with scripts executing only after the page&rsquo;s content was fully loaded. While this improved perceived loading times, it still did not provide full control over script loading and execution order, especially for pages with heavy JavaScript.<\/li>\r\n<\/ul>\r\n<p><strong>Introduction of <code>async<\/code> and <code>defer<\/code><\/strong>:<\/p>\r\n<ul>\r\n<li>As web applications became more complex and reliant on JavaScript, the need for more sophisticated loading strategies became apparent. The <code>async<\/code> and <code>defer<\/code> attributes were introduced to give developers better control over the loading and execution of scripts without compromising page performance.<\/li>\r\n<li><strong><code>async<\/code><\/strong>: Allows scripts to be downloaded in the background and executed as soon as they&rsquo;re downloaded, without waiting for the entire page to be parsed. This is ideal for scripts that are independent of other scripts and don&rsquo;t modify the DOM immediately.<\/li>\r\n<li><strong><code>defer<\/code><\/strong>: Enables scripts to be downloaded in parallel with HTML parsing but delays script execution until after the HTML document has been fully parsed. This is useful for scripts that need to interact with the entire DOM and ensures scripts execute in the order they appear in the document.<\/li>\r\n<\/ul>\r\n<p><strong>Key Differences<\/strong><\/p>\r\n<ul>\r\n<li><strong>Control Over Execution<\/strong>: <code>async<\/code> and <code>defer<\/code> provide more precise control over when scripts are loaded and executed relative to the parsing of the HTML document. This contrasts with the more binary choice of placing scripts in the <code>&lt;head&gt;<\/code> or at the end of the <code>&lt;body&gt;<\/code>, which does not offer the same level of granularity.<\/li>\r\n<li><strong>Performance Optimization<\/strong>: By allowing scripts to be loaded asynchronously or deferred until after parsing, <code>async<\/code> and <code>defer<\/code> help minimize the performance impact of JavaScript on page load times. Traditional placement methods, while still useful in some cases, generally result in less optimized loading behavior.<\/li>\r\n<li><strong>Modern Web Development Practices<\/strong>: The introduction of <code>async<\/code> and <code>defer<\/code> reflects a broader shift towards optimizing user experience by improving site speed and interactivity. These attributes are part of modern web development best practices aimed at creating fast, responsive websites.<\/li>\r\n<\/ul>\r\n<p>The evolution from simply placing scripts in specific locations within the HTML document to using <code>async<\/code> and <code>defer<\/code> attributes represents a shift towards more sophisticated and performance-oriented web development practices. These modern attributes offer developers the tools needed to balance the necessity of JavaScript with the demand for fast and responsive web pages.<\/p>\r\n<h3 id=\"what-does-it-mean-when-a-web-page-is-interactive\">What does it mean when a web page is interactive?<\/h3>\r\n<p>When a web page is interactive, it means that users can engage with the content beyond just reading it. This includes actions like clicking buttons, filling out forms, selecting options from menus, or any other activity where the page responds to user input. An interactive page allows for a dynamic experience, offering personalized features or responses based on how the user interacts with the web elements on the page.<\/p>\r\n<h3 id=\"what-happens-if-a-user-tries-to-interact-with-a-page-that-hasnt-rendered\">What happens if a user tries to interact with a page that hasn&rsquo;t rendered?<\/h3>\r\n<p class=\"\">If a user tries to interact with a page that hasn&rsquo;t fully rendered, they might find that their clicks, taps, or inputs have no effect. This is because the interactive elements like buttons, forms, or links are not yet functional until the page is fully loaded and the browser has executed the necessary JavaScript. This can lead to a frustrating user experience, as the visual elements might appear ready before they&rsquo;re actually interactive.<\/p>\r\n<h3 class=\"\" id=\"remove-unused-cssjs-with-w3-total-cache-pro\">Remove Unused CSS\/JS with W3 Total Cache Pro<\/h3>\r\n<p class=\"\">And here&rsquo;s an exciting update: with the latest version of W3 Total Cache, we introduced an powerful new&nbsp; feature &ndash; <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/remove-cssjs\/\" target=\"_blank\" rel=\"noopener\">Remove Unused CSS &amp; JavaScript<\/a>. Unused CSS and JavaScript files contribute to the bloat of your website&rsquo;s codebase, increasing load times and hindering user experience. When visitors access your site, their browsers are required to download and parse every CSS and JS file linked to the page, even if they&rsquo;re not utilized. This results in unnecessary HTTP requests, consuming bandwidth and slowing down the rendering process.<\/p>\r\n<p class=\"\">Removing Unused CSS &amp; JS eliminates unnecessary code from your website, further enhancing its speed and efficiency. Combine this approach with other optimization techniques, such as eliminating render-blocking resources, to unlock the full potential of your website&rsquo;s performance with one of the <a href=\"https:\/\/www.boldgrid.com\/5-best-wordpress-cache-plugins\/\">best WordPress cache plugins<\/a> available.<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<!-- \/wp:heading --><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>There are two major things that must load before your website can be &ldquo;rendered,&rdquo; the Document Object Model (DOM) and the CSSOM (Cascading Style Sheet Object Model). The DOM contains all of the markups for your website, and the CSSOM contains all of the styling to display it correctly. In WordPress, most CSS files, or [&hellip;]<\/p>\n","protected":false},"author":880,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"","bgseo_description":"","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[741,692],"tags":[],"class_list":["post-89438","post","type-post","status-publish","format-standard","hentry","category-minify","category-w3-total-cache"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/89438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/880"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=89438"}],"version-history":[{"count":26,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/89438\/revisions"}],"predecessor-version":[{"id":148103,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/89438\/revisions\/148103"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=89438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=89438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=89438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}