[wp-trac] [WordPress Trac] #55151: View scripts of blocks are loaded in editor

WordPress Trac noreply at wordpress.org
Tue Feb 15 17:28:28 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  |     Focuses:  javascript, performance
------------------------------+--------------------------------------
Changes (by ocean90):

 * owner:  (none) => ocean90
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"52733" 52733]:
 {{{
 #!CommitTicketReference repository="" revision="52733"
 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.
 Fixes #55151.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55151#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list