Answer the question
In order to leave comments, you need to log in
How to remove the attribute type="text/javascript" and type="text/css" in the body of site pages on Wordpress?
Good afternoon!
Can you please tell me how to remove the type="text/javascript" and type="text/css" attributes from the type code
<script type='text/javascript'>
/* <![CDATA[ */
....
/* ]]> */
</script>
<style type="text/css">
.header_top {...}
</style>
Answer the question
In order to leave comments, you need to log in
Link - https://wordpress.stackexchange.com/questions/2878...
Should help
add_action( 'wp_enqueue_scripts', 'myplugin_enqueue' );
function myplugin_enqueue() {
// wp_register_script(...
// wp_enqueue_script(...
}
add_filter('style_loader_tag', 'myplugin_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'myplugin_remove_type_attr', 10, 2);
function myplugin_remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question