[wp-trac] [WordPress Trac] #55151: View scripts of blocks are loaded in editor
WordPress Trac
noreply at wordpress.org
Thu Feb 17 09:09:26 UTC 2022
#55151: View scripts of blocks are loaded in editor
-------------------------------------+-------------------------------------
Reporter: ocean90 | Owner: ocean90
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.9.1
Component: Editor | Version: 5.9
Severity: normal | Resolution: fixed
Keywords: has-patch commit fixed- | Focuses: javascript,
major dev-feedback | performance
-------------------------------------+-------------------------------------
Changes (by ocean90):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"52745" 52745]:
{{{
#!CommitTicketReference repository="" revision="52745"
Editor: Prevent front-end assets of a block from being enqueued in the
block editor.
Since WordPress 5.9 you can set a view script for a block which is
supposed to be only loaded on the front end. Unfortunately it's currently
also loaded in the editor which can cause unexpected behaviour and also
performance issues depending on the size of the scripts.
This is caused by the preloading of REST API routes via
`block_editor_rest_api_preload()` which doesn't happen in an encapsulated
process and so does pollute any global state like the one for scripts and
styles.
Similar to the global `$post`, core now backups the globals `$wp_scripts`
and `$wp_styles` and restores the backup after the preloading.
Props gziolo, ocean90.
Merges [52733] to the 5.9 branch.
Fixes #55151.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55151#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list