Created
November 15, 2019 05:01
-
-
Save adamrosloniec/59bd772829a6b1064c6fba48f634ffdf to your computer and use it in GitHub Desktop.
WordPress - Eliminate render-blocking resources
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
function addRelPreloadTagToEnqueueStyles($html, $handle) { | |
// Put to array all styles which you want to add tag rel="preload" | |
$styles = ['app', 'wp-block-library', 'contact-form-7', 'cf7cf-style']; | |
foreach ($styles as $singleStyle) { | |
$html = preg_replace("/id='" . $singleStyle . "-css'/", " id='" . $singleStyle . "-css' rel='preload' as='style' ", $html); | |
} | |
return $html; | |
} | |
add_filter('style_loader_tag', 'addRelPreloadTagToEnqueueStyles'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment