wp_scripts(): WP_Scripts
- Since
- 4.2.0
- Source
wp-includes/functions.wp-scripts.php:20
Compatibility
- WordPress
- since 4.2.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
WP_Scripts- WP_Scripts instance.
Performance profile
How much work a call to wp_scripts() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 4–7
- Plugin surface
- None
- Called by
- 17
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 7.
Nothing here hands control to plugin code.
17 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_scripts() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4–7 | none |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 7 instructions, 4–7 executed per call, 1 branch. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- WP_Scripts::__construct()Constructor.
Used by · 17
- TwentyTwenty_Script_Loader::filter_script_loader_tag()Adds async/defer attributes to enqueued / registered scripts.
- TwentyTwenty_Script_Loader::migrate_legacy_strategy_script_data()Migrates legacy async/defer script data which might be used by child themes.
- WP_Customize_Nav_Menus::enqueue_scripts()Enqueues scripts and styles for Customizer pane.
- _WP_Editors::force_uncompressed_tinymce()Force uncompressed TinyMCE when a custom theme has been defined.
- _wp_customize_loader_settings()Adds settings for the customize-loader script.
- load_script_textdomain()Loads the script translated strings.
- print_head_scripts()Prints the script queue in the HTML head on admin pages.
- wp_add_inline_script()Adds extra code to a registered script.
- wp_dequeue_script()Removes a previously enqueued script.
- wp_deregister_script()Removes a registered script.
- wp_enqueue_script()Enqueues a script.
- wp_localize_script()Localizes a script.
Show all 17
- wp_plupload_default_settings()Prints default Plupload arguments.
- wp_print_scripts()Prints scripts in document head that are in the $handles queue.
- wp_register_script()Registers a new script.
- wp_script_add_data()Adds metadata to a script.
- wp_script_is()Determines whether a script has been added to the queue.
Source code
function wp_scripts() { global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { $wp_scripts = new WP_Scripts(); } return $wp_scripts;}Changelog
Introduced in 4.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/functions.wp-scripts.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.