[wp-trac] [WordPress Trac] #50328: Enqueue script and style assets only for blocks present on the page

WordPress Trac noreply at wordpress.org
Wed Jul 1 19:30:31 UTC 2020


#50328: Enqueue script and style assets only for blocks present on the page
-------------------------+-------------------------
 Reporter:  aduth        |       Owner:  gziolo
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  5.5
Component:  Editor       |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  javascript
-------------------------+-------------------------

Comment (by westonruter):

 Replying to [comment:4 gziolo]:
 > It looks like the following check fixes the issue for the editor:
 >
 > {{{#!php
 > <?php
 > $skip_assets = is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) &&
 REST_REQUEST );
 > }}}
 >
 > I'm not sure it's the best way to approach it though.

 This is similar to what was done for Atomic Blocks in
 https://github.com/studiopress/atomic-blocks/pull/297

 So I think that approach makes sense. I didn't need to do this in the
 syntax-highlighting-code-block plugin because the CSS is only ever added
 in the `render_callback` on the frontend. So the CSS is not needed in the
 editor.

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


More information about the wp-trac mailing list