Replies: 0
Hi,
i tried to remove the type attribute from the style and script tags with the following code snippet:
//* Remove type tag from script and style
add_filter('style_loader_tag', 'codeless_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'codeless_remove_type_attr', 10, 2);
function codeless_remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
In the un-cached version it works. It seems so that autoptimize add those attributes to the cached website.
On validator.w3.org i get some warnings because those attributes are no longer needed.
Examples:
Warning: The type attribute for the style element is not needed and should be omitted.
Warning: The type attribute is unnecessary for JavaScript resources.