Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add a action to enqueue stylesGist for my "WorpdPress: Css Styles and Javascripts in theme development (In depth)" article:
function my_theme_optimize_script_tags( $tag , $handle , $src )
/* add async defer attributes */
$defer = ( $handle == 'my-theme-scripts' ) ? 'async defer' : '';
return "<script id='{$handle}' {$defer} src='{$src}'></script>" . "\n";
add_filter('script_loader_tag', 'my_theme_optimize_script_tags', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.