• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Eliminate Render-blocking Javascript and CSS WordPress

By Abhishek Ghosh November 10, 2013 5:44 am Updated on October 14, 2016

Eliminate Render-blocking Javascript and CSS WordPress

Advertisement

Eliminate Render-blocking Javascript and CSS WordPress – Possibly all the users of WordPress face this dangerous looking warning in Google PageSpeed Insights. As Google has not developed WordPress or possibly do not use WordPress, they unfortunately has set some rules which have to follow. We have nothing to do but solve this issue. It does not mean that Google has set a wrong rule. But it means that, it is not easy to do by an average user, which Google has not considered. This Eliminate Render-blocking Javascript and CSS warning is normal and comes as default with WordPress and almost all Content Management System. Run the test for `wordpress.org’ and you will also get the same error – Eliminate Render-blocking Javascript and CSS. As WordPress and Google do not need hundreds of Social Media buttons, for WordPress dot org, the score hits towards 90/100, we score around 84/100.

Update on 14th Oct, 2016.

Quick info on Eliminate Render-blocking Javascript and CSS For WordPress:

This is non-blocking way for individual CSS :

Vim
1
<link rel="stylesheet" href="https://cdn.domain.com/my.css" media="none" onload="if(media!='all')media='all'">

Why, that is explained in How to Load CSS Without Blocking Rendering.

This is non-blocking way for individual Js :

Vim
1
<script type='text/javascript' src='https://cdn.domain.com/my.js' async defer>execOnReady(function(){execOnReady(function(){});});</script>

 

Eliminate Render-blocking Javascript and CSS WordPress : The Pathophysiology of the Errors

 

Eliminate Render-blocking Javascript and CSS can be of two types, at least for WordPress :

  • The verbatim language –  Eliminate Render-blocking Javascript and CSS… ; which means the source is Internal or from your own domain.
  • With External word added – Eliminate External Render-blocking Javascript and CSS…; which means the source is External or from other domain like social network.

You must know what is WP Enqueue Script For WordPress Themes. With that, you must have idea about wp deregister script function :

Advertisement

---

 

Vim
1
http://codex.wordpress.org/Function_Reference/wp_deregister_script

 

Eliminate Render-blocking Javascript and CSS WordPress

Unfortunately, unlike wp_Enqueue function, wp deregister script has limitations – you practically can not deregister all the things you want. The reason is basically limited parameters versus wp_Enqueue function.

As basically the CSS file(s) and Javascript file(s) are usually added in the header with link rel, instead of naked inserting the CSS and Javascripts (check any webpage of Google and also Bloggers Blog), this files actually defers the website to be visible to human. In other words, you have to remove this automated insertion and put them manually using the above described functions.

 

Eliminate Render-blocking Javascript and CSS WordPress : Wow, Fix it Then

 

It is practically very very difficult. First, the usual way we do for Page Speed Optimization is using W3 Total Cache or WP Super Cache Plugin (with WP Minify or some other Plugin). W3 Total Cache, currently is superior but unfortunately, W3 Total Cache d not support wp deregister script at the time of writing. In other words – do not use the minify function of W3 Total Cache as a first step.

So, you got lot of separate non-minified files at the frontend now. For CSS files :

  1. Take all the CSS files
  2. Combine them manually
  3. Minify them manually (there are online free tools)
  4. Deregister all the plugin generated CSS output from functions.php file of your Theme / Child Theme
  5. Add the whole thing within style markup in this way –

 

You can use any Plugin or your Theme’s function to insert code to do this.

Regarding Javascripts, thankfully, for jQuery there are enqueue function to put the scripts at footer and defer them. Unfortunately, defering or loading at footer can become unacceptable for certain web design. Code goes here :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Deregister is limited in function arguments, plugin-name is the name with which the plugin or theme is registered
*/
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
 
function my_deregister_styles() {
wp_deregister_style( 'plugin-name' );
wp_deregister_style( 'my-theme-css' );
}
/**
* Register new JavaScript file.
* @see WP_Dependencies::add() For parameter information.
*/
function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
$wp_scripts = new WP_Scripts();
$wp_scripts->add( $handle, $src, $deps, $ver );
if ( $in_footer )
$wp_scripts->add_data( $handle, 'group', 1 );
}
/**
* Enqueues script.
* Registers the script if source is provided and enqueues.
*/
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
$wp_scripts = new WP_Scripts();
if ( $src ) {
$_handle = explode('?', $handle);
$wp_scripts->add( $_handle[0], $src, $deps, $ver );
if ( $in_footer )
$wp_scripts->add_data( $_handle[0], 'group', 1 );
}
$wp_scripts->enqueue( $handle );
}
 
/**
* Just an Example
*/
if (function_exists('load_my_scripts')) {  
    function load_my_scripts() {  
        if (!is_admin()) {  
        wp_deregister_script( 'jquery' );  
        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');  
        wp_enqueue_script('jquery');  
        wp_register_script('myscript', bloginfo('template_url').'/js/myScript.js'__FILE__), array('jquery'), '1.0', true );  
        wp_enqueue_script('myscript');  
        }  
    }  
}  
add_action('init', 'load_my_scripts');
/**
* Just an Example, put in to footer with relative path:
*/
wp_enqueue_script('jquery','/wp-includes/js/jquery/jquery.js','','',true);

Obviously, you will put all these on a CDN and serve them. Yes, it was great if there were some sort of Plugin, but unfortunately there is no fool-proof plugin exists. You will get better score on the webpages where there is no social networking buttons. Embedding Stylesheet within the webpage has advantages which we wrote in our guide To Have a Faster WordPress Get a Faster Database. There is a phenomenon named Flash of Unstyled Content “ hitting the browser back button makes the page to load without the stylesheet. We know because we are using Internet for commercial purpose before WordPress and Google arrived. This is why we said “It does not mean that Google has set a wrong rule” at the beginning.
Another way will be to make the website to flat HTML and do the works. That turns using WordPress meaningless.

Updated on 10th April, 2014 : Also Read About Defer Parsing Javascript Method.

Tagged With Remove render-blocking JavaScript wordpress , ERROR Asset render failed: css/main css , wordpress how to Eliminate render-blocking JavaScript and CSS without plugin , using wp super cache elimate render blocking , remove render blocking scripts w3 total cache , remove render blocking javascript for wordpress , plugin eliminate render-blocking javascrip , js render non blocking , how to remove render blocking javascript , wordpress how to stop render blocking scripts

This Article Has Been Shared 813 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Eliminate Render-blocking Javascript and CSS WordPress

  • Cloud OS eyeOS on Your Own Server – Step by Step Guide to Install

    Cloud OS eyeOS can be installed on any server running LAMP. We will install our Cloud OS on a usual server, not Cloud Server in this example.

  • Cloud Computing Benchmark

    Cloud Computing Benchmark Standard is needed to quantify and standardize the performance from various Cloud Computing service providers.

  • Cloud Computing Expo – Enterprise IT Event in Nov 2011

    Cloud Computing Expo first started in 2007. As usually, this year the Cloud Computing Expo will focus on the current development and opportunities in the field.

  • Myths About Private Cloud

    Myths About Private Cloud decreases the chance of expandability for a company or an organization.Both public and hybrid cloud computing can be used selectively.

  • New Trends in Cloud Computing

    New trends in cloud computing means, seeking some new way and finding the answer whether to use it. Cloud computing has become a real trend from the media hype. Cloud Computing is a good option when you know about the points on security, the definite flaws, the weaker sides. There are three related article which […]

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023
  • What is Vehicular Ad-Hoc Network? January 24, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Eliminate Render-blocking Javascript and CSS WordPress," in The Customize Windows, November 10, 2013, January 31, 2023, https://thecustomizewindows.com/2013/11/eliminate-render-blocking-javascript-and-css-wordpress/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT