Skip to content

Instantly share code, notes, and snippets.

@insaurabh
Created May 10, 2019 06:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save insaurabh/46eac17e4e4badc694dcf42944978b1d to your computer and use it in GitHub Desktop.
Save insaurabh/46eac17e4e4badc694dcf42944978b1d to your computer and use it in GitHub Desktop.
Preload css in wordpress.
// preload css in wordpress
// add this code in child theme function.php
add_filter( 'style_loader_tag', 'preload_css', 10, 2 );
function preload_css( $html, $handle ){
$targetHanlde = array('zuhaus_mikado_child_style');
if( in_array( $handle, $targetHanlde ) ){
$html = str_replace("rel='stylesheet'", "rel='preload'", $html);
}
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment