[wp-trac] [WordPress Trac] #44709: Allow for late loading of scripts added via wp_add_inline_script()
WordPress Trac
noreply at wordpress.org
Thu Aug 2 18:40:33 UTC 2018
#44709: Allow for late loading of scripts added via wp_add_inline_script()
---------------------------+--------------------------------------
Reporter: woodent | Owner: woodent
Type: enhancement | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: 4.5
Severity: normal | Keywords: dev-feedback needs-patch
Focuses: |
---------------------------+--------------------------------------
Inline scripts added via `wp_add_inline_script()` are only output when the
referenced script file is loaded. If an inline script is added after a
referenced script file has already been output, the inline script won't be
output.
Much like how `wp_enqueue_script()` can be used within a shortcode to
enqueue a file in the footer even though it would normally be loaded in
the head; I propose that `wp_add_inline_script()` should output the inline
script even if the referenced script file has already been loaded.
Since we can't predict when a script file that was loaded in the footer
might be loaded into the head due to a third-party script with it as a
dependency, `wp_add_inline_script()` should also be flexible and not break
things by simply not outputting the code in those cases.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44709>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list