Script File loads in Editor although it is not linked via "Editor Script"

@MichelyWeb @Wolfgang.Hartl, well, this was enlightening :slight_smile:

By default, WordPress loads styles and scripts of all registered blocks on the front-end, regardless if blocks are used on the page or not. It appears the change happened in WP 5.8.

To load only assets of blocks that are used on the page, add the following code to inc/custom.php:

add_filter( 'should_load_separate_core_block_assets', '__return_true' );

Starting from Pinegrow Web Editor 7.8, WordPress plugin 1.0.15 and Theme Converter 2.2 (next updates) the WordPress builder can do this for you if you enable the Load only styles and scripts of blocks that are displayed on the front-end checkbox in project settings:

I added the above to our docs on block styling and scripts:

4 Likes