Created
May 10, 2019 06:49
-
-
Save insaurabh/46eac17e4e4badc694dcf42944978b1d to your computer and use it in GitHub Desktop.
Preload css in wordpress.
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
// 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