[wp-trac] [WordPress Trac] #54956: [5.9] wp_block_type args - "style" and "script" are always loaded on Frontend

WordPress Trac noreply at wordpress.org
Fri Jul 8 11:00:01 UTC 2022


#54956: [5.9] wp_block_type args - "style" and "script" are always loaded on
Frontend
-------------------------------+------------------------------
 Reporter:  pkostadinov        |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Editor             |     Version:  5.9
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by pkostadinov):

 In my original comment I mentioned using "styles and view_script"
 parameters, but this didn't solve the issue.

 So far I haven't found a solution, I went through some of the code changes
 between 5.8.3 and 5.9, and still haven't found a way to fix this myself. I
 still havent found the exact location where the WP Core decides if it
 should load registered styles.

 I have prepared an example child theme, for showing the most simple code
 that reproduces the issue. The child was made for the 3rd most popular
 theme - hello-elementor, but it will work with almost any theme.

 https://github.com/pkostadinov90/test-register-block

 The entire issue could be described with one screenshot (actually 4
 screenshots):

 [[Image(https://raw.githubusercontent.com/pkostadinov90/test-register-
 block/main/custom-child/screenshot.jpg)]]

 I am really sorry @hellofromTonya, but your testing was related to the
 native gutenberg blocks, and not custom ones. As per my original comment -
 the problem is when you register a custom block with register_block_type.

 TLDR; Short answers to the questions above:

 - Step-by-step instructions
 register_block_type - register 2 different blocks, each with diffent css
 handle in the "style" argument;
 Also it doesn't matter when wp_register_style was called, the issue is
 happening regardless if called on init or wp_enqueue_scripts; This is
 visible in my test child theme

 - The code for any custom blocks you're using
 https://github.com/pkostadinov90/test-register-block

 - The theme you're using
 Any theme, but in the test case I created a child theme for hello-
 elementor

 - A list of plugins that are activated
 None / No plugins active

 - Any environment information such as nginx or IIS, browser, etc.
 nginx/1.18.0 (Ubuntu) and nginx/1.14.0 (Ubuntu), PHP 8.0.18 and PHP 8.0.9,
 not browser dependant

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


More information about the wp-trac mailing list