[wp-trac] [WordPress Trac] #58632: Add support for 'async' and 'defer' loading to script that use inline scripts.
WordPress Trac
noreply at wordpress.org
Thu Jun 29 16:05:24 UTC 2023
#58632: Add support for 'async' and 'defer' loading to script that use inline
scripts.
---------------------------+------------------------------
Reporter: joemcgill | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: performance
---------------------------+------------------------------
Old description:
> This is a follow-up to #12009.
>
> While adding support for registering a script with an 'async' or 'defer'
> loading strategy, the solution that was committed [56033] did not include
> support for scripts that have an inline script attached in the 'after'
> position, nor if any script that is a dependent of the script has an
> inline script attached in the after position. In either scenario, the
> original script will be printed without the registered loading strategy
> in order to maintain execution order of the scripts in the dependency
> chain when an inline script is included.
>
> The purpose of this ticket is to reopen discussion about adding support
> for this use case. An initial implementation that included support for
> this use case was included in [https://github.com/WordPress/wordpress-
> develop/pull/4391/ the initial PR] prior to removal in
> [https://github.com/WordPress/wordpress-
> develop/pull/4391/commits/b7d362df9655eedd2aff8651addd497fca83f1d0 this
> commit]. Relevant conversation on the initial ticket that led to the
> decision to remove support for inline scripts starts at
> [https://core.trac.wordpress.org/ticket/12009#comment:111 this comment].
New description:
This is a follow-up to #12009.
While adding support for registering a script with an 'async' or 'defer'
loading strategy, the solution that was committed [56033] did not include
support for scripts that have an inline script attached in the 'after'
position, nor if any script that is a dependent of the script has an
inline script attached in the after position. In either scenario, the
original script will be printed without the registered loading strategy in
order to maintain execution order of the scripts in the dependency chain
when an inline script is included.
The purpose of this ticket is to reopen discussion about adding support
for this use case. An initial implementation that included support for
this use case was included in [https://github.com/WordPress/wordpress-
develop/pull/4391/ the initial PR] prior to removal in
[https://github.com/WordPress/wordpress-
develop/pull/4391/commits/b7d362df9655eedd2aff8651addd497fca83f1d0 this
commit] (from [https://github.com/10up/wordpress-develop/pull/81 squashed
PR]). Relevant conversation on the initial ticket that led to the decision
to remove support for inline scripts starts at
[https://core.trac.wordpress.org/ticket/12009#comment:111 this comment].
--
Comment (by westonruter):
For some more code history on delayed inline scripts (which were reverted
prior to core commit), see these PRs:
* [https://github.com/10up/wordpress-develop/pull/67 Add delayed inline
before scripts and remove standalone inline scripts]
* [https://github.com/10up/wordpress-develop/pull/75 Script Loading
Strategies: Ensure wp_print_delayed_inline_script_loader() outputs when
needed]
* [https://github.com/10up/wordpress-develop/pull/80 Improve handling of
delayed strategies when dependency aliases (bundles) are involved]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58632#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list