Skip to content

Instantly share code, notes, and snippets.

@jasenmichael
Forked from nfsarmento/simple-map-defer.php
Last active August 7, 2021 21:51
Show Gist options
  • Save jasenmichael/247ea19292ccfa495698da879b5438c4 to your computer and use it in GitHub Desktop.
Save jasenmichael/247ea19292ccfa495698da879b5438c4 to your computer and use it in GitHub Desktop.
WordPress defer javascript filter
/**
* defer javascript!
*
*/
function defer_parsing_of_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_of_js', 11, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment