V
V
ventacom2018-03-07 15:00:35
Search Engine Optimization
ventacom, 2018-03-07 15:00:35

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>

or
<style type="text/css">
  .header_top {...}
</style>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-03-07
@azerphoenix

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 question

Ask a Question

731 491 924 answers to any question