Last active
August 29, 2015 14:21
-
-
Save sky4git/c27f141fe5095427a0c0 to your computer and use it in GitHub Desktop.
Async Wordpress Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: This filter can go into functions.php | |
function add_defer_to_wp( $url ) | |
{ | |
if ( FALSE === strpos( $url, '.js' ) ) | |
{ // not our file | |
return $url; | |
} | |
// Must be a ', not "! | |
return "$url' async"; | |
} | |
add_filter( 'clean_url', 'add_defer_to_wp', 11, 1 ); | |
//if you want it to defer Please visit: https://gist.github.com/toscho/1584783 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment