How can I defer these JS files?
-
In my website, I used GTmetrix and I got JS defer error on following two files.
92.5KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering.
https://mysite.url/wp-includes/js/jquery/jquery.js?ver=1.12.4 (87.0KiB)
https://mysite.url/ (5.5KiB of inline JavaScript)
In my functions.php file I have following code to defer js but it seems not affected for js file(s) outside the theme folder.
Here’s my piece of code in functions.php file
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 ); }
How can I get rid of that error and defer parsing above mentioned items?
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How can I defer these JS files?’ is closed to new replies.