[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes
WordPress Trac
noreply at wordpress.org
Mon Jun 19 12:32:02 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 commit | Focuses: performance
---------------------------------------------+--------------------------
Comment (by spacedmonkey):
Replying to [comment:128 azaozz]:
> Generally speaking the "script after" functionality promotes writing of
mediocre JS (scripts that require additional JS code snippets to be
outputted from PHP in order to work). This was somewhat useful ~10 years
ago as many WP devs had good knowledge of PHP but weren't particularly
well versed in JS. However in 2023 I'd like to think that most WP devs
have a deep understanding of JS, and can implement anything they may need
or want with "pure" JS, with no need of PHP "crutches" :)
There are many examples of where after is used in core script with great
success. A couple of scripts that are important include.
wp-i18n
heartbeat
wp-api-fetch
wp-blocks
wp-date
After can be missed used. But in many cases it is correctly used by
developer to pass data from PHP to javascript. Take for example moment,
that uses it to setup translated dates.
{{{#!php
<script id='moment-js-after'>
moment.updateLocale( 'en_US',
{"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"week":{"dow":1},"longDateFormat":{"LT":"g:i
a","LTS":null,"L":null,"LL":"F j, Y","LLL":"F j, Y g:i a","LLLL":null}} );
</script>
}}}
Supporting after makes sense to me, as it is widely and correctly used by
developers.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12009#comment:130>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list