Skip to content

Instantly share code, notes, and snippets.

@willybahuaud
Created August 30, 2016 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willybahuaud/6cfaf5a06f643852b7491f7f34a8de0a to your computer and use it in GitHub Desktop.
Save willybahuaud/6cfaf5a06f643852b7491f7f34a8de0a to your computer and use it in GitHub Desktop.
Launch Prism for heavy pages
<?php
// add data-manual attribute, then call Prism in async way
add_filter( 'script_loader_tag', 'pastacode_async', 10, 3 );
function pastacode_async ( $tag, $handle, $src ) {
if ( 'prismjs' == $handle ) {
$tag = str_replace( '<script ', '<script data-manual ', $tag );
$tag .= '<script>jQuery(document).ready(function($){Prism.highlightAll(true);});</script>';
}
return $tag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment