Created
April 16, 2018 08:48
-
-
Save mrkkr/8515bc1f81491b827acf1475da3f39e9 to your computer and use it in GitHub Desktop.
How to add async tag to script in Wordpress #php
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
///in functions.php | |
<?php | |
function add_async_attribute($tag, $handle) { | |
if ( 'SCRIPT_NAME' !== $handle ) | |
return $tag; | |
return str_replace( ' src', ' async src', $tag ); | |
} | |
add_filter('script_loader_tag', 'add_async_attribute', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment