[wp-trac] [WordPress Trac] #42804: type is not required in HTML5

WordPress Trac noreply at wordpress.org
Sat Dec 18 18:58:31 UTC 2021


#42804: type is not required in HTML5
--------------------------------------------+-----------------------------
 Reporter:  sasiddiqui                      |       Owner:  SergeyBiryukov
     Type:  task (blessed)                  |      Status:  closed
 Priority:  low                             |   Milestone:  5.3
Component:  Script Loader                   |     Version:
 Severity:  normal                          |  Resolution:  fixed
 Keywords:  needs-testing has-patch commit  |     Focuses:
--------------------------------------------+-----------------------------

Comment (by GermanKiwi):

 Hi @SergeyBiryukov et al,

 I have a plugin which adds a `<script>` tag to the footer of every page,
 and the tag includes the `type="module"` attribute.

 I've discovered that if I use the "add_theme_support" function to add
 html5 support for scripts, it not only results in the
 `type="text/javascript"` attribute being removed from all `<script>` tags,
 but the `type="module"` attribute is also removed too, which is a problem
 - this attribute is still needed and still valid under HTML5.

 The description of this patch at the top of this page is incorrect to
 state that "type is no more required" under HTML5 - in fact, only the
 JavaScript MIME type is no longer required. Other values for type, such as
 "module", are still valid:
 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

 Question: is it possible the patch provided here is also stripping out the
 `type="module"` attribute?

 If so, could that please be reversed or fixed, so that this attribute is
 not removed?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42804#comment:45>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list