Title: WP_Script_Modules::print_import_map
Published: April 3, 2024
Last modified: February 24, 2026

---

# WP_Script_Modules::print_import_map()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_script_modules/print_import_map/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_script_modules/print_import_map/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_script_modules/print_import_map/?output_format=md#changelog)

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

Prints the import map using a script tag with a type=”importmap” attribute.

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

    ```php
    public function print_import_map() {
    	$import_map = $this->get_import_map();
    	if ( ! empty( $import_map['imports'] ) ) {
    		wp_print_inline_script_tag(
    			(string) wp_json_encode( $import_map, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),
    			array(
    				'type' => 'importmap',
    				'id'   => 'wp-importmap',
    			)
    		);
    	}
    }
    ```

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

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

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

Returns the import map array.

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

Prints an inline script tag.

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

Encodes a variable into JSON, with some confidence checks.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_script_modules/print_import_map/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_script_modules/print_import_map/?output_format=md#)

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

| Version | Description | 
| [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%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_script_modules%2Fprint_import_map%2F)
before being able to contribute a note or feedback.