Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer parsing of JS for those speedy load times #6

Open
nicdford opened this issue Mar 4, 2019 · 1 comment
Open

Defer parsing of JS for those speedy load times #6

nicdford opened this issue Mar 4, 2019 · 1 comment

Comments

@nicdford
Copy link
Owner

nicdford commented Mar 4, 2019

https://www.hostinger.com/tutorials/wordpress/how-to-defer-parsing-of-javascript-in-wordpress

@nicdford
Copy link
Owner Author

// Defer Parsing of JS
// Credit to https://stackoverflow.com/questions/18944027/how-do-i-defer-or-async-this-wordpress-javascript-snippet-to-load-lastly-for-fas
add_filter( 'clean_url', function( $url )
{
    if ( FALSE === strpos( $url, '.js' ) )
    { // not our file
        return $url;
    }
    // Must be a ', not "!
    return "$url' defer='defer";
}, 11, 1 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant