Title: How to eliminate render-blocking JavaScript and CSS
Last modified: August 31, 2016

---

# How to eliminate render-blocking JavaScript and CSS

 *  [nasy84](https://wordpress.org/support/users/nasy84/)
 * (@nasy84)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/how-to-eliminate-render-blocking-javascript-and-css-1/)
 * Hi,
 * I have this:
 * Eliminate render-blocking JavaScript and CSS in above-the-fold content
    Your 
   page has 4 blocking script resources and 15 blocking CSS resources.
 *  [http://ermagazin.com/…-includes/js/jquery/jquery.js?ver=1.11.3](http://ermagazin.com/…-includes/js/jquery/jquery.js?ver=1.11.3)
   
   [http://ermagazin.com/…s/jquery/jquery-migrate.min.js?ver=1.2.1](http://ermagazin.com/…s/jquery/jquery-migrate.min.js?ver=1.2.1)
   [http://ermagazin.com/…e-theme/js/owl.carousel.min.js?ver=4.4.2](http://ermagazin.com/…e-theme/js/owl.carousel.min.js?ver=4.4.2)
   [http://ermagazin.com/…dmin-ajax.php?action=ot_dynamic_js&ver=1](http://ermagazin.com/…dmin-ajax.php?action=ot_dynamic_js&ver=1)
 * The solution for this I found at: [https://varvy.com/pagespeed/defer-loading-javascript.html](https://varvy.com/pagespeed/defer-loading-javascript.html)
 * Its a step how to defer loading of javascript
 * So I added this code in HTML before </body>
 *     ```
       <script type="text/javascript">
       function downloadJSAtOnload() {
       var element = document.createElement("script");
       element.src = "defer.js";
       document.body.appendChild(element);
       }
       if (window.addEventListener)
       window.addEventListener("load", downloadJSAtOnload, false);
       else if (window.attachEvent)
       window.attachEvent("onload", downloadJSAtOnload);
       else window.onload = downloadJSAtOnload;
       </script>
       ```
   
 * [Moderator note: code fixed. Please wrap code in the backtick character or [use the code button](https://codex.wordpress.org/Forum_Welcome#Posting_Code).]
 * Just I need to replace this “defer.js” with a name of my external JS file.
 * But what is the name of my external file JS file?
 * My site is [ermagazin.com](http://ermagazin.com)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [10 years, 2 months ago](https://wordpress.org/support/topic/how-to-eliminate-render-blocking-javascript-and-css-1/#post-7089904)
 * Hi nasy84!
 * Have you thought about using a plugin rather than hard-coding that? A quick Google
   search shows a good way of going about it:
 * [http://wpcodesnippet.com/add-async-and-defer-attributes-javascript-elements/](http://wpcodesnippet.com/add-async-and-defer-attributes-javascript-elements/)
 * Hope that helps!
 *  Thread Starter [nasy84](https://wordpress.org/support/users/nasy84/)
 * (@nasy84)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/how-to-eliminate-render-blocking-javascript-and-css-1/#post-7089920)
 * Thank you Jose 🙂
 * I just added at the bottom of functions.php this code:
 *     ```
       // add async and defer to javascripts
       function wcs_defer_javascripts ( $url ) {
           if ( FALSE === strpos( $url, '.js' ) ) return $url;
           if ( strpos( $url, 'jquery.js' ) ) return $url;
           return "$url' async='async";
       }
       add_filter( 'clean_url', 'wcs_defer_javascripts', 11, 1 );
       ```
   
 * But, I don’t see any improvement, when I check, the message is still there, and
   load speed is the same,
 * Recommend please some of plugin…
 * [Moderator note: code fixed. Please wrap code in the backtick character or [use the code button](https://codex.wordpress.org/Forum_Welcome#Posting_Code).]

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to eliminate render-blocking JavaScript and CSS’ is closed to new
replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [load speed](https://wordpress.org/support/topic-tag/load-speed/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [nasy84](https://wordpress.org/support/users/nasy84/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/how-to-eliminate-render-blocking-javascript-and-css-1/#post-7089920)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
