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

WordPress Trac noreply at wordpress.org
Thu May 11 20:38:26 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:106 mor10]:
 > I'm not back. This is me from the past adding context to an old issue.

 Uh, I see :(

 > As per MDN: "For module scripts, if the async attribute is present then
 the scripts and all their dependencies will be executed in the defer queue

 Right. This is another drawback here, imho. Script loader is the "legacy"
 way to load scripts. The modern way for modern JS (like Gutenberg/the
 block editor) is to load modules. Unfortunately Script loader is
 incompatible with that. I've looked a bit at possibilities to incorporate
 Script loader with JS modules. Seems possible (perhaps with few few
 caveats).

 I'd really love to see a patch/refactoring of the way WP loads scripts
 that brings that functionality from 2008 to 2023 :)

 > `async` and `defer` are not optional features; they are part of the web
 platform. Adding one but not the other is arbitrary and works counter to
 the intent of the platform itself. It also makes a decision on behalf of
 WordPress developers that runs counter to how the web works.

 Hmm, perhaps there is a bit on misunderstanding here. There are no
 attempts to "ban" scripts with `async` in WP. The problems discussed here
 are about the features of the Script loader API, and how they can or
 cannot be used with `async` scripts. I.e. are there any use cases to have
 `async` scripts as dependents or dependencies? Extending any API for
 "theoretical" use cases is not a good idea.

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


More information about the wp-trac mailing list