[wp-trac] [WordPress Trac] #52320: Empty entries in WP_Scripts 'extra' field
WordPress Trac
noreply at wordpress.org
Mon Jan 18 08:55:06 UTC 2021
#52320: Empty entries in WP_Scripts 'extra' field
---------------------------+-----------------------------
Reporter: vanyukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: trunk
Severity: trivial | Keywords:
Focuses: |
---------------------------+-----------------------------
When WordPress registers all the scripts in `wp_default_scripts()` the
`add_inline_script()` will often add `false` to the extra field of the
script. That `false` value does not do anything and can be easily removed
by comparing against empty data from `get_data()` in
`add_inline_script()`. Doesn't look like this has any effect on anything,
as `false` values will later on be ignored. But this will save a few extra
bytes of memory.
Steps to verify:
* Get the `$wp_scripts` global
* Check some registered scripts, for example
`$wp_scripts->registered->editor->extra['after']`. It will have two array
values - one is `false` and one is the actual data `window.wp.oldEditor =
window.wp.editor;`
Or via debugging by putting a breakpoint in `wp-includes/class.wp-
scripts.php` in `add_inline_script()` for `$script = (array)
$this->get_data( $handle, $position );`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52320>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list