Created
February 24, 2021 07:16
-
-
Save chavesm/f5468769a08b29add7af35cdd0b06af6 to your computer and use it in GitHub Desktop.
WordPress filter hook that tries to remove unnecessary "text/javascript" and "text/css" from HTML source. Add to Child theme's functions.php.
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 | |
/** Try to Remove Unnecessary "text/javascript" and "text/css" */ | |
function codeless_remove_type_attr($tag, $handle) { | |
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag ); | |
} | |
add_filter('style_loader_tag', 'codeless_remove_type_attr', 10, 2); | |
add_filter('script_loader_tag', 'codeless_remove_type_attr', 10, 2); | |
/** Credit: Codeless https://codeless.co/remove-type-attribute-from-wordpress/ */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment