wp_scripts_get_suffix( string $type = '' ): string
- Since
- 5.0.0
- Source
wp-includes/script-loader.php:680
Description
There are two suffix types, the normal one and the dev suffix.
Compatibility
- WordPress
- since 5.0.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.
Parameters
$typestringoptional- The type of suffix to retrieve.Default:
''
Return value
string- The script suffix.
Performance profile
How much work a call to wp_scripts_get_suffix() 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
- 8–34
- Plugin surface
- None
- Called by
- 11
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 38.
Nothing here hands control to plugin code.
11 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_scripts_get_suffix() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 8–30 | none |
$suffixes === null && !defined('SCRIPT_DEBUG') | 32–34 | define() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 38 | 8–34 | 5 | |
| 8.5 | 38 | 8–34 | 5 | |
| 8.4 | 38 | 8–34 | 5 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 41 | 8–37 | 5 | |
| 8.2 | 41 | 8–37 | 5 | |
| 8.1 | 41 | 8–37 | 5 | |
| 7.4 | 41 | 8–37 | 5 |
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.
Used by · 11
- _print_emoji_detection_script()Prints inline Emoji detection script.
- get_post_embed_html()Retrieves the embed code for a specific post.
- print_embed_scripts()Prints the JavaScript in the embed iframe header.
- register_core_block_style_handles()Registers core block style handles.
- wp_add_editor_classic_theme_styles()Loads classic theme styles on classic themes in the editor.
- wp_default_packages_scripts()Registers all the WordPress packages scripts that are in the standardized `js/dist/` location.
- wp_default_packages_vendor()Registers all the WordPress vendor scripts that are in the standardized `js/dist/vendor/` location.
- wp_default_script_modules()Registers all the default WordPress Script Modules.
- wp_default_scripts()Registers all WordPress scripts.
- wp_enqueue_embed_styles()Enqueues the CSS in the embed iframe header.
- wp_register_tinymce_scripts()Registers TinyMCE scripts.
Source code
function wp_scripts_get_suffix( $type = '' ) { static $suffixes; if ( null === $suffixes ) { /* * Include an unmodified $wp_version. * * Note: wp_get_wp_version() is not used here, as this file can be included * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case * wp-includes/functions.php is not loaded. */ require ABSPATH . WPINC . '/version.php'; /* * Note: str_contains() is not used here, as this file can be included * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case * the polyfills from wp-includes/compat.php are not loaded. */ $develop_src = false !== strpos( $wp_version, '-src' ); if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', $develop_src ); } $suffix = SCRIPT_DEBUG ? '' : '.min'; $dev_suffix = $develop_src ? '' : '.min'; $suffixes = array( 'suffix' => $suffix, 'dev_suffix' => $dev_suffix, ); } if ( 'dev' === $type ) { return $suffixes['dev_suffix']; } return $suffixes['suffix'];}Changelog
Introduced in 5.0.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.8.8 tag, from
src/wp-includes/script-loader.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.