Created
June 10, 2021 14:05
-
-
Save jonbrockett/9c265adc604d886c1f2b9d607b24f1ae to your computer and use it in GitHub Desktop.
Remove type= from <script> and <style>
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
/** Remove type= from <script> and <style> */ | |
require_once 'library/type-remove.php'; |
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
<?php | |
/** | |
* Remove type= from <script> and <style> | |
* | |
* This will remove these HTML5 markup warnings | |
*/ | |
//* Remove type tag from script and style | |
add_filter('style_loader_tag', 'remove_type_attr', 10, 2); | |
add_filter('script_loader_tag', 'remove_type_attr', 10, 2); | |
add_filter('autoptimize_html_after_minify', 'remove_type_attr', 10, 2); | |
function remove_type_attr($tag, $handle='') | |
{ | |
return preg_replace("/type=['\"]text\/(javascript|css)['\"]/", '', $tag); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment