{"id":2632,"date":"2022-09-29T09:47:05","date_gmt":"2022-09-29T09:47:05","guid":{"rendered":"https:\/\/tronsdev.com\/tronsit.au\/?p=1693"},"modified":"2022-09-29T09:47:05","modified_gmt":"2022-09-29T09:47:05","slug":"remove-render-blocking-css","status":"publish","type":"post","link":"https:\/\/tronsdev.com\/tronsit\/remove-render-blocking-css\/","title":{"rendered":"Remove Render Blocking CSS"},"content":{"rendered":"<h1>Remove Render Blocking CSS in WordPress<\/h1>\n<p>The Cascading Style Sheets are files that contain data and functionalities related to a website\u2019s style and appearance. To make a WordPress website load fast, it is not just vital to remove render-blocking JavaScript but also to remove render-blocking CSS.<br \/>\nAll externally linked CSS are render-blocking and make a website slow. The reason being, browsers do not tend to load CSS files unless they have been completely downloaded which consumes a little more time. To ease out the process it is important to defer them but remember not to defer them as JS, it will damage your website.<br \/>\nTo defer and eliminate render-blocking one must follow the following steps:<\/p>\n<ul>\n<li>Create a safe back up<\/li>\n<\/ul>\n<p>It is always essential to create safe backups when modifying code in any way, this lowers down the risk of not being able to recover a website.<\/p>\n<ul>\n<li>Access critical CSS<\/li>\n<\/ul>\n<p>To access critical CSS, you will need to use online \u2018critical path CSS generating\u2019 tools. Once that you get access to the CSS file, copy the code and save it for later use.<\/p>\n<ul>\n<li>Defer CSS stylesheets<\/li>\n<\/ul>\n<p>To make this possible access the functions.php file paste the following code in it:<\/p>\n<pre>function add_rel_preload($html, $handle, $href, $media) {\nif (is_admin())\nreturn $html;\n$html = &lt;&lt;&lt;EOT\nEOT;\nreturn $html;\n}\nadd_filter( 'style_loader_tag', 'add_rel_preload', 10, 4 );<\/pre>\n<p>By adding this code, you will attribute the CSS to preload, this means that now the rendering shall take place simultaneously as other elements of the website load. But wait! The task isn\u2019t done yet.<br \/>\nBy using this code, the CSS may load simultaneously as other elements, but the website will look broken or in other words \u2018unstyled\u2019. This is because the CSS is responsible for styling a website either above-the-fold or below-the-fold. To recover the look, you will now have to follow the following step:<\/p>\n<ul>\n<li>Use Critical CSS<\/li>\n<\/ul>\n<p>Use the following code snippet and paste it into the functions.php file:<\/p>\n<pre>function hook_css() {\n?&gt;\n[insert critical css here]\n<!--?php &lt;br ?--> }\nadd_action('wp_head', 'hook_css');<\/pre>\n<p>Paste the critical CSS derived in Step 2 into the [insert critical css here] part. Make sure that you do not forget to add the<\/p>\n<p>&nbsp;<\/p>\n<p>tags. This will recover the website\u2019s look as now the CSS important for above-the-fold will render before others.<br \/>\nOnce that you have followed the above-mentioned steps, the website will load normally but with an evident difference in the speed. With a faster website, you can attract great leads as well as add value to the website\u2019s SEO practices.<br \/>\nWant to learn more? Comment below to start a conversation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Remove Render Blocking CSS in WordPress The Cascading Style Sheets are files that contain data and functionalities related to a website\u2019s style and appearance. To make a WordPress website load fast, it is not just vital to remove render-blocking JavaScript but also to remove render-blocking CSS. All externally linked CSS are render-blocking and make a &#8230; <a title=\"Remove Render Blocking CSS\" class=\"read-more\" href=\"https:\/\/tronsdev.com\/tronsit\/remove-render-blocking-css\/\" aria-label=\"Read more about Remove Render Blocking CSS\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":2751,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[26],"class_list":["post-2632","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website-development","tag-website-development"],"_links":{"self":[{"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/posts\/2632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/comments?post=2632"}],"version-history":[{"count":0,"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/posts\/2632\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/media\/2751"}],"wp:attachment":[{"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/media?parent=2632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/categories?post=2632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tronsdev.com\/tronsit\/wp-json\/wp\/v2\/tags?post=2632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}