1

script type="text/javascript" is optional in HTML5 and all browsers (even old ones) recognize JavaScript without it. I am building an HTML5 site and want my script output to be consistent. However, scripts that use the WordPress enqueue function are printed withtype="text/javascript".

CSS is also printed with type="text/css", which is also not needed.

I can't find a filter to remove those properties. Is there one?

4

This is hardcoded in WP_Scripts->do_item() method ( source ) and probably same for styles. So it cannot be filtered.

As alternative you can extend class with modified version of this method and replace instance in global $wp_scripts variable.

  • 1
    Actually the style loader is a little better in that sense, you can hook onto style_loader_tag and adjust whatever parts of the link element(ie. <link =""> etc..) you like, there's unfortunately no equivalent for the script loader... :( – t31os Jan 30 '11 at 16:39
  • Rarst, can you elaborate on how to do this? Thanks – envysea Oct 1 '13 at 17:12
  • @envysea it's not something I would recommend doing in practice, especially if you not up to implementing and maintaining such solution on updates. – Rarst Oct 1 '13 at 18:37
  • Open issue in progress at core.trac.wordpress.org/ticket/13592 ++ See also script_loader_src filter at wordpress.stackexchange.com/questions/47206/… – here Nov 18 '14 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.