Defer parsing JavaScript on Wordpress

function defer_parsing_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_js', 11, 1 );
This code should be copied to the bottom of your theme’s functions.php file. The if not admin is used because in the backend you can break a lot of things if you use it.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.