Title: Deferring Javascript causes plugin to fail
Last modified: August 22, 2016

---

# Deferring Javascript causes plugin to fail

 *  [roothost](https://wordpress.org/support/users/roothost/)
 * (@roothost)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/deferring-javascript-causes-plugin-to-fail/)
 * I installed your plugin today and noticed a problem with it not displaying if
   we have set Javascript files to defer loading.
 * We have this
 *     ```
       if (!(is_admin() )) {
           function defer_parsing_of_js ( $url ) {
               if ( FALSE === strpos( $url, '.js' ) ) return $url;
               if ( strpos( $url, 'jquery.js' ) ) return $url;
               // return "$url' defer ";
               return "$url' defer onload='";
           }
           add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
       }
       ```
   
 * in our functions.php to help speed up load times and it seems.
 * The plugin doesn’t work on the front-end with this function installed. Removing
   it instantly fixes the issue.
 * We have tried several other plugins similar to yours, and they all work absolutely
   fine with or without the defer function in place.
 * Any ideas on a fix for this?
 * [https://wordpress.org/plugins/cookie-law-info/](https://wordpress.org/plugins/cookie-law-info/)

Viewing 1 replies (of 1 total)

 *  [Richard](https://wordpress.org/support/users/richardashby/)
 * (@richardashby)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/deferring-javascript-causes-plugin-to-fail/#post-5707812)
 * Hi, this will probably be because of the order in which the JavaScripts are output.
   I’ll look into it at some point but I’m not going to have time to do anything
   in the next few weeks unfortunately. The main change will be to output the JSON
   string in the header and the Cookie Law Info JavaScript in the footer, all of
   which will need to be tested on a whole bunch of themes (it’s always the testing
   that’s the time consuming part). Sounds like you’re pretty techie so if you are
   up for making the fix yourself and repost then I’ll happily incorporate it and
   credit you with the solution?

Viewing 1 replies (of 1 total)

The topic ‘Deferring Javascript causes plugin to fail’ is closed to new replies.

 * ![](https://ps.w.org/cookie-law-info/assets/icon.svg?rev=3007243)
 * [CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice)](https://wordpress.org/plugins/cookie-law-info/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-law-info/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-law-info/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-law-info/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-law-info/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-law-info/reviews/)

## Tags

 * [defer javascript](https://wordpress.org/support/topic-tag/defer-javascript/)
 * [javascript conflict](https://wordpress.org/support/topic-tag/javascript-conflict/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)

 * 1 reply
 * 2 participants
 * Last reply from: [Richard](https://wordpress.org/support/users/richardashby/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/deferring-javascript-causes-plugin-to-fail/#post-5707812)
 * Status: not resolved