May 7, 2015

How To Fix Eliminate Render-Blocking JavaScript And CSS Problem

|
When you check your blog with Google PageSpeed Insights, and you see this remark:

 Consider Fixing:

Eliminate render-blocking JavaScript and CSS in above-the-fold content.


This is what can do to overcome the aforementioned problem.

Paste this set of code into the functions.php of your WordPress.

function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.min.js' ) ) return $url;
    return "$url' defer='defer";
  }
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
Then click Update File button.

Now check with Google PageSpeed Insights see if there is any change of page loading speed.

Caution: Follow this tutorial at your own risk. I am saying this because functions.php of WordPress is very sensitive.

If you paste any code that is not "acceptable", you will be locked out of your own site!

* Anyway, here is the tutorial on how to fix WordPress Function.php  Error: Cannot Log-In And Site Disappear.