[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes

WordPress Trac noreply at wordpress.org
Mon May 29 09:51:51 UTC 2023


#12009: Add support for HTML 5 "async" and "defer" attributes
-------------------------------------------------+-------------------------
 Reporter:  Otto42                               |       Owner:  10upsimon
     Type:  enhancement                          |      Status:  assigned
 Priority:  high                                 |   Milestone:  6.3
Component:  Script Loader                        |     Version:  4.6
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests 2nd-        |     Focuses:
  opinion                                        |  performance
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Replying to [comment:113 joemcgill]:

 > > Does adding support for async and defer would make it harder or
 impossible to add support for module scripts in WordPress?
 >
 > This is a good question, and one I’m continuing to review, but initially
 I don’t see there being a conflict here. According to
 [https://html.spec.whatwg.org/multipage/scripting.html#the-script-
 element:~:text=This%20is%20all%20summarized%20in%20the%20following%20schematic%20diagram%3A
 the spec], any scripts added with `type="module"` are automatically loaded
 using a deferred strategy, but can also support `async` if present.

 Right. However I'm looking more at the way module scripts are loaded:

  A recent addition to JavaScript modules functionality is dynamic module
 loading. This allows you to dynamically load modules only when they are
 needed, rather than having to load everything up front. This has some
 obvious performance advantages

 See: https://developer.mozilla.org/en-
 US/docs/Web/JavaScript/Guide/Modules#dynamic_module_loading. This seems
 somewhat incompatible with Script Loader (no idea what's going to be
 loaded and when), and currently I'm unsure if adding "async" and "defer"
 might make that incompatibility larger. Imho exploring this now would be a
 really good thing.

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


More information about the wp-trac mailing list