Skip to content

Instantly share code, notes, and snippets.

@steveclason
Created January 8, 2017 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveclason/27fafd3faf3467450e94f01d185959c0 to your computer and use it in GitHub Desktop.
Save steveclason/27fafd3faf3467450e94f01d185959c0 to your computer and use it in GitHub Desktop.
WordPress, defer loading of specific script(s).
// script_loader_tag is new as of WP 4.1
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
if ( 'contact-form-7' !== $handle )
return $tag;
return str_replace( ' src', ' defer="defer" src', $tag );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment