How to add ASYNC to all the enqueue scripts in WordPress

July 11th, 2016 by
Simple add this filter to your theme functions.php file.
add_filter( 'clean_url', function( $url )
{
    if ( FALSE === strpos( $url, '.js' ) )
    { 
        return $url;
    }
    return "$url' async='async";
}, 11, 1 );

Post a Comment

You must be logged in to post a comment.

Cached at: 2024-12-21 02:54:15pm