Last active
December 13, 2021 10:48
-
-
Save seojacky/a42e97b9d666aac4311be77958865c0e to your computer and use it in GitHub Desktop.
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 | |
/* Async CSS */ | |
add_filter( 'style_loader_tag', 'async_css_change_attribute', 10, 2 ); | |
function async_css_change_attribute($link, $handle) { | |
$marks = array( | |
'hide-admin-bar-based-on-user-roles', | |
'post-views-counter-frontend', | |
'wsl-widget', | |
'slick-theme', | |
'slickstyle', | |
'rgg-style', | |
'rgg-simplelightbox', | |
'mihdan-lite-youtube-embed', | |
); | |
if(in_array($handle, $marks)) { | |
$link = str_replace( '\'all\'', '\'print\'', $link ); | |
$link = str_replace( '/>', 'onload="this.media=\'all\'" />', $link ); | |
} | |
return $link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment