Title: type attributes
Last modified: March 3, 2021

---

# type attributes

 *  Resolved [Insect Trojan](https://wordpress.org/support/users/insecttrojan/)
 * (@insecttrojan)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/type-attributes/)
 * hello autoptimize cant remove my type=’text/javascript’ how can i fix it because
   the validator.w3.org says Warning: The type attribute is unnecessary for JavaScript
   resources. thanks a lot
 * is this right ?
 * // Remove ‘type’ attribute of scripts and styles
 * if ( ! function_exists( ‘prefix_remove_type_attr’ ) ) {
 *  function prefix_remove_type_attr( $tag ) {
    return preg_replace( “/type=[‘\”]
   text\/(javascript|css)[‘\”]/”, ”, $tag ); }
 *  add_filter( ‘style_loader_tag’, ‘prefix_remove_type_attr’, 10 );
    add_filter(‘
   script_loader_tag’, ‘prefix_remove_type_attr’, 10 ); add_filter( ‘autoptimize_html_after_minify’,‘
   prefix_remove_type_attr’, 10 ); // ‘Autoptimize’ plugin support
 * }
    -  This topic was modified 5 years, 2 months ago by [Insect Trojan](https://wordpress.org/support/users/insecttrojan/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ftype-attributes%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/type-attributes/#post-14126222)
 * AO doesn’t add type attributes itself, so I suppose you’re talking about non-
   autoptimized resources. but the code snippet looks OK at first sight, yes 🙂
 * frank
 *  Thread Starter [Insect Trojan](https://wordpress.org/support/users/insecttrojan/)
 * (@insecttrojan)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/type-attributes/#post-14126256)
 * yes i talking for non autoptimize resources. thanks a lot

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘type attributes’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Insect Trojan](https://wordpress.org/support/users/insecttrojan/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/type-attributes/#post-14126256)
 * Status: resolved