JamesHusband
12/19/2016 - 4:04 PM

Function for adding ASYNC tag to JS Scripts

Function for adding ASYNC tag to JS Scripts

    // 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 );