Title: load_script_module_textdomain
Published: May 20, 2026

---

# load_script_module_textdomain( string $id, string $domain = 'default', string $path = '' ): string|false

## In this article

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

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

Loads the translation data for a given script module ID and text domain.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/load_script_module_textdomain/?output_format=md#description)󠁿

Works like [load_script_textdomain()](https://developer.wordpress.org/reference/functions/load_script_textdomain/)
but for script modules registered via [wp_register_script_module()](https://developer.wordpress.org/reference/functions/wp_register_script_module/).

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

 `$id`stringrequired

The script module identifier.

`$domain`stringoptional

Text domain. Default `'default'`.

Default:`'default'`

`$path`stringoptional

The full file path to the directory containing translation files.

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/load_script_module_textdomain/?output_format=md#return)󠁿

 string|false The JSON-encoded translated strings for the given script module and
text domain.
 False if there are none.

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

    ```php
    function load_script_module_textdomain( string $id, string $domain = 'default', string $path = '' ) {
    	$module = wp_script_modules()->get_registered( $id );
    	if ( null === $module ) {
    		return false;
    	}
    	$src = $module['src'];

    	// Ensure src is an absolute URL for path resolution.
    	if ( ! preg_match( '|^(https?:)?//|', $src ) ) {
    		$src = site_url( $src );
    	}

    	return _load_script_textdomain_from_src( $id, $src, $domain, $path, true );
    }
    ```

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

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

| Uses | Description | 
| [_load_script_textdomain_from_src()](https://developer.wordpress.org/reference/functions/_load_script_textdomain_from_src/)`wp-includes/l10n.php` |

Resolves and loads the translation JSON file for a given script or script module source URL.

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

Gets the data for a registered script module.

  | 
| [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.

  | 
| [site_url()](https://developer.wordpress.org/reference/functions/site_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.

  |

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

Prints translations for all enqueued script modules.

  |

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

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.0.0/) | Introduced. |

## User Contributed Notes

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