[wp-trac] [WordPress Trac] #51124: Can we get an additional parameter in wp_add_inline_script to set the script type?
WordPress Trac
noreply at wordpress.org
Fri Sep 25 16:04:35 UTC 2020
#51124: Can we get an additional parameter in wp_add_inline_script to set the
script type?
----------------------------------------+------------------------------
Reporter: hcabrera | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: good-first-bug needs-patch | Focuses:
----------------------------------------+------------------------------
Changes (by Otto42):
* keywords: => good-first-bug needs-patch
Comment:
+1
This is a good idea. Additionally, the script tag can also be used for
adding structured data using type="application/ld+json".
See here for more information:
https://developers.google.com/search/docs/guides/intro-structured-data
Also, given that the text/javascript is the default for scripts, having
type="text/javascript" there is not needed, and the latest W3 validation
tool actually returns a warning for it with "The type attribute is
unnecessary for JavaScript resources."
So it might be worth removing that default as well, and allowing for
registered scripts to change the type via some data attached to the
handle. Then only output the type attribute when it's explicitly set by
the code.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51124#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list