I have various javascripts that are necessary plugins in one of my WordPress domains, and I know where in the php file it\'s called from.
I\'m taking every measure I
Or more universal way:
function add_async_forscript($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_forscript', 11, 1);
so you can add async to any script without code changes, just add #asyncload to script url as:
wp_enqueue_script('dcsnt', '/js/jquery.social.media.tabs.1.7.1.min.js#asyncload' )