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: |
|
Owned by: |
|
|---|---|---|---|
| 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
#2
@
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.
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