Created
January 8, 2017 20:50
-
-
Save steveclason/27fafd3faf3467450e94f01d185959c0 to your computer and use it in GitHub Desktop.
WordPress, defer loading of specific script(s).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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