Created
August 29, 2019 06:17
-
-
Save premanshup/72199b22f58528f128124d51ec941326 to your computer and use it in GitHub Desktop.
Defer Parsing of Astra Theme JS
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
/** | |
* Add async attr to the Astra Script. | |
* | |
* @param string $tag Tag for the script. | |
* @param string $handle Handle for the script. | |
* | |
* @return string | |
*/ | |
function add_async_attribute( $tag, $handle ) { | |
if ( 'astra-theme-js' === $handle ) { | |
return str_replace( ' src', ' async="async" src', $tag ); | |
} | |
return $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