Due to W3C validation warnings that I would like to avoid, I currently use the following snippet in my functions file to remove the type attribute from enqueued scripts and stylesheets:
// Remove type attribute from scripts and stylesheets
add_filter('style_loader_tag', 'remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'remove_type_attr', 10, 2);
function remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
But this doesn't work on files loaded by plugins. Does anyone know of a solution to this problem?