Make WordPress Core

Opened 9 months ago

Closed 9 months ago

#63413 closed defect (bug) (fixed)

Unused global variables declared in wp_enqueue_registered_block_scripts_and_styles

Reported by: umeshnevase's profile umesh.nevase Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: normal
Severity: normal Version: 5.0
Component: Script Loader Keywords: has-patch commit
Focuses: Cc:

Description

We should remove the unused global variables if it is not required because opcode and parsing overhead. I could not find any use of the global variables in the function and also no other code is depends on it.

I found this while enqueuing assets for my theme in wp-includes/script-loader.php at wp_enqueue_registered_block_scripts_and_styles()

Change History (6)

This ticket was mentioned in PR #8784 on WordPress/wordpress-develop by umeshnevase.


9 months ago
#1

There is unsed global vriable added in code but not used anywhere. We should remove it for extra overhead for code parsing and Opcode Compilation.
I've removed that global variable and from function data.
The global is variable not used anywhere in function and not required.

Trac ticket: https://core.trac.wordpress.org/ticket/63413#ticket

#2 @b1ink0
9 months ago

After looking at the file history, I found that in #537(https://github.com/WordPress/wordpress-develop/pull/537) the _should_load_block_editor_scripts_and_styles() helper was introduced and the screen-check logic was moved into it. However, the global $current_screen; declaration in wp_enqueue_registered_block_scripts_and_styles() was left behind. Since the function no longer uses $current_screen, this global could probably be removed.

@mukesh27 commented on PR #8784:


9 months ago
#3

Thanks for the PR, it looks good to me. Let’s wait for the unit tests to pass.

#4 @mukesh27
9 months ago

  • Component changed from General to Script Loader
  • Focuses performance coding-standards removed
  • Keywords needs-testing removed
  • Milestone changed from Awaiting Review to 6.9
  • Version changed from 6.8 to 5.0

#5 @mukesh27
9 months ago

  • Keywords commit added

#6 @SergeyBiryukov
9 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 60230:

Script Loader: Remove unused global when enqueuing block scripts and styles.

Follow-up to [44164], [49080], [49093], [50836], [50919], [59823].

Props umesh.nevase, b1ink0, mukesh27.
Fixes #63413.

Note: See TracTickets for help on using tickets.