Skip to content

Instantly share code, notes, and snippets.

@alokstha1
Created May 1, 2017 05:59
Show Gist options
  • Save alokstha1/b253e87b804a88eb3c13c87c50b44f69 to your computer and use it in GitHub Desktop.
Save alokstha1/b253e87b804a88eb3c13c87c50b44f69 to your computer and use it in GitHub Desktop.
Defer Parsing of Javascript
<?php
function cpm_defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer='defer";
}
add_filter( 'clean_url', 'cpm_defer_parsing_of_js', 11, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment