Title: wp_register_script_module
Published: April 3, 2024
Last modified: May 20, 2026

---

# wp_register_script_module( string $id, string $src,  $deps = array(), string|false|null $version = false,  $args = array() )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#wp--skip-link--target)

Registers the script module if no script module with that script module identifier
has already been registered.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#parameters)󠁿

 `$id`stringrequired

The identifier of the script module. Should be unique. It will be used in the final
import map.

`$src`stringoptional

Full URL of the script module, or path of the script module relative to the WordPress
root directory. If it is provided and the script module has not been registered 
yet, it will be registered.

`string|bool`> $args { Optional. An array of additional args. Default empty array.
@
type bool $in_footer Whether to print the script module in the footer. Only relevant
to block themes. Default `'false'`. Optional. @type `'auto'|'low'|'high'` $fetchpriority
Fetch priority. Default `'auto'`. Optional. }

`$version`string|false|nulloptional

String specifying the script module version number. Defaults to false.
 It is added
to the URL as a query string for cache busting purposes. If $version is set to false,
the version number is the currently installed WordPress version. If $version is 
set to null, no version is added.

Default:`false`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#source)󠁿

    ```php
    function wp_register_script_module( string $id, string $src, array $deps = array(), $version = false, array $args = array() ) {
    	wp_script_modules()->register( $id, $src, $deps, $version, $args );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/script-modules.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/script-modules.php#L71)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/script-modules.php#L71-L73)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Script_Modules::register()](https://developer.wordpress.org/reference/classes/wp_script_modules/register/)`wp-includes/class-wp-script-modules.php` |

Registers the script module if no script module with that script module identifier has already been registered.

  | 
| [wp_script_modules()](https://developer.wordpress.org/reference/functions/wp_script_modules/)`wp-includes/script-modules.php` |

Retrieves the main [WP_Script_Modules](https://developer.wordpress.org/reference/classes/wp_script_modules/) instance.

  |

| Used by | Description | 
| [wp_register_page_routes()](https://developer.wordpress.org/reference/functions/wp_register_page_routes/)`wp-includes/build/routes.php` |

Generic helper function to register routes for a page.

  | 
| [wp_options_connectors_wp_admin_enqueue_scripts()](https://developer.wordpress.org/reference/functions/wp_options_connectors_wp_admin_enqueue_scripts/)`wp-includes/build/pages/options-connectors/page-wp-admin.php` |

Enqueue scripts and styles for the options-connectors-wp-admin page.

  | 
| [wp_options_connectors_render_page()](https://developer.wordpress.org/reference/functions/wp_options_connectors_render_page/)`wp-includes/build/pages/options-connectors/page.php` |

Render the options-connectors page.

  | 
| [wp_font_library_render_page()](https://developer.wordpress.org/reference/functions/wp_font_library_render_page/)`wp-includes/build/pages/font-library/page.php` |

Render the font-library page.

  | 
| [wp_font_library_wp_admin_enqueue_scripts()](https://developer.wordpress.org/reference/functions/wp_font_library_wp_admin_enqueue_scripts/)`wp-includes/build/pages/font-library/page-wp-admin.php` |

Enqueue scripts and styles for the font-library-wp-admin page.

  | 
| [wp_default_script_modules()](https://developer.wordpress.org/reference/functions/wp_default_script_modules/)`wp-includes/script-modules.php` |

Registers all the default WordPress Script Modules.

  | 
| [register_block_script_module_id()](https://developer.wordpress.org/reference/functions/register_block_script_module_id/)`wp-includes/blocks.php` |

Finds a script module ID for the selected block metadata field. It detects when a path to file was provided and optionally finds a corresponding asset file with details necessary to register the script module under with an automatically generated module ID. It returns unprocessed script module ID otherwise.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_register_script_module/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Added the $args parameter. | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fsiteproxy.ruqli.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_script_module%2F)
before being able to contribute a note or feedback.