Skip to content

Instantly share code, notes, and snippets.

@aristath
Last active March 23, 2016 09:20
Show Gist options
  • Save aristath/276df8415ee96b4aa13b to your computer and use it in GitHub Desktop.
Save aristath/276df8415ee96b4aa13b to your computer and use it in GitHub Desktop.
Add async in scripts. See https://developers.google.com/speed/docs/insights/BlockingJS for details
<?php
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
return preg_replace( "/(><\/[a-zA-Z][^0-9](.*)>)$/", " async $1 ", $tag );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment