Created
May 24, 2021 09:52
-
-
Save wtmujeebu/a941b8bff26a4239fe0b60d8de30d285 to your computer and use it in GitHub Desktop.
Optimize CSS - CookieYes GDPR Cookie Consent
This file contains hidden or 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
<?php | |
function wt_cli_add_rel_preload($html, $handle, $href, $media) { | |
$preload = array( | |
'cookie-law-info', | |
'cookie-law-info-gdpr', | |
'cookie-law-info-table' | |
); | |
if (in_array($handle, $preload)) { | |
return '<link rel="preload" as="style" onload="this.onload=null;this.rel=' . "'stylesheet'" . '" id="' . $handle . '-css" href="' . $href . '" type="text/css" media="all" />' . "\n"; | |
} | |
return $html; | |
} | |
add_filter( 'style_loader_tag', 'wt_cli_add_rel_preload', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment