Created
February 1, 2016 21:29
-
-
Save jmsmrgn/ee194c55afaaaec69dd9 to your computer and use it in GitHub Desktop.
WP - Async script load
This file contains hidden or 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
// Async load | |
function async_scripts($url) { | |
if (strpos( $url, '#asyncload') === false) { | |
return $url; | |
} else if (is_admin()) { | |
return str_replace('#asyncload', '', $url ); | |
} else { | |
return str_replace('#asyncload', '', $url )."' async='async"; | |
} | |
} | |
add_filter('clean_url', 'async_scripts', 11, 1); | |
// '.js#asyncload' will add async='async' to tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment