Created
December 19, 2016 16:04
-
-
Save JamesHusband/96c5f583876d64e034341a56a42a2837 to your computer and use it in GitHub Desktop.
Function for adding ASYNC tag to JS 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
// Async load | |
function add_async_to_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', 'add_async_to_scripts', 11, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment