[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes
WordPress Trac
noreply at wordpress.org
Sun Dec 22 13:28:43 UTC 2019
#12009: Add support for HTML 5 "async" and "defer" attributes
---------------------------+-----------------------------
Reporter: Otto42 | Owner: azaozz
Type: enhancement | Status: reopened
Priority: normal | Milestone: Future Release
Component: Script Loader | Version: 4.6
Severity: normal | Resolution:
Keywords: | Focuses:
---------------------------+-----------------------------
Comment (by apedog):
> **New {{{wp_enqueue_script()}}} signature**
This comment is about {{{wp_enqueue_script()}}} signature. Not about
implementation.
I might be late to the party, but I've not seen any serious discussion on
this.
I believe {{{wp_enqueue_script()}}} should get an additional
{{{$parsing_attr}}} parameter. Like so:
{{{
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer,
$parsing_attr=null )
}}}
Where {{{parsing_attr}}} defaults to {{{null}}} but can be set to
{{{'defer'}}} or {{{'async'}}}. No need to allow for both. {{{defer}}} and
{{{async}}} can be mutually exclusive IMO.
Ideally {{{in_footer}}} could have been overloaded, but since a truth-y
{{{in_footer}}} value prints the script in the footer, this would
invalidate the use of {{{defer}}} and {{{async}}} (which are also truth-y,
but useless on scripts loaded in the footer).
So a separate parameter is, alas, the safer way to go.
This seems to me to be the least likely candidate to break old plugins. At
the cost of a long, convoluted signature.
Does anything need to happen outside of this ticket in order to change the
signature of such a widely-used function?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12009#comment:64>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list