[ WordPress.org  ](https://wordpress.org/)

  * [ News  ](https://wordpress.org/news/)
  * [ Showcase  ](https://wordpress.org/showcase/)
  * [ Hosting  ](https://wordpress.org/hosting/)
  * Extend 
    * [ Themes  ](https://wordpress.org/themes/)
    * [ Plugins  ](https://wordpress.org/plugins/)
    * [ Patterns  ](https://wordpress.org/patterns/)
    * [ Blocks  ](https://wordpress.org/blocks/)
    * [ Openverse  ↗  ︎  ](https://openverse.org/)
  * Learn 
    * [ Learn WordPress  ](https://learn.wordpress.org/)
    * [ Documentation  ](https://wordpress.org/documentation/)
    * [ Forums  ](https://wordpress.org/support/forums/)
    * [ Developers  ](https://developer.wordpress.org/)
    * [ WordPress.tv  ↗  ︎  ](https://wordpress.tv/)
  * Community 
    * [ Make WordPress  ](https://make.wordpress.org/)
    * [ Photo Directory  ](https://wordpress.org/photos/)
    * [ Five for the Future  ](https://wordpress.org/five-for-the-future/)
    * [ Events  ](https://events.wordpress.org/)
    * [ Job Board  ↗  ︎  ](https://jobs.wordpress.net/)
  * About 
    * [ About WordPress  ](https://wordpress.org/about/)
    * [ Enterprise  ](https://wordpress.org/enterprise/)
    * [ Gutenberg  ↗  ︎  ](https://wordpress.org/gutenberg/)
    * [ Swag Store  ↗  ︎  ](https://mercantile.wordpress.org/)
  * [ Get WordPress  ](https://wordpress.org/download/)

Search in WordPress.org

[ Get WordPress ](https://wordpress.org/download/)

[ WordPress.org  ](https://wordpress.org/)

[ WordPress Developer Resources ](https://developer.wordpress.org)

WP_Scripts::print_extra_script()

  * [ Developer Blog  ](https://developer.wordpress.org/news/)
  * [ Code Reference  ](https://developer.wordpress.org/reference/)
  * [ WP-CLI Commands  ](https://developer.wordpress.org/cli/commands/)

  * [ Developer Blog  ](https://developer.wordpress.org/news/)
  * [ Code Reference  ](https://developer.wordpress.org/reference/)
  * [ WP-CLI Commands  ](https://developer.wordpress.org/cli/commands/)

[ Home ](https://developer.wordpress.org) [ Reference
](https://developer.wordpress.org/reference/) [ Classes
](https://developer.wordpress.org/reference/classes/) [ WP_Scripts
](https://developer.wordpress.org/reference/classes/wp_scripts/)
WP_Scripts::print_extra_script()

Search

#  WP_Scripts::print_extra_script(  string  $handle  ,  bool  $display  =
true  ):  bool|string|void

##  In this article

Table of Contents

  * Parameters 
  * Return 
  * Source 
  * Related 
  * Changelog 

↑  Back to top

Prints extra scripts of a registered script.

##  Parameters

` $handle ` string  required

    

The script’s registered handle.

` $display ` bool  optional

    

Whether to print the extra script instead of just returning it.

Default: ` true `

##  Return

bool|string|void  Void if no data exists, extra scripts if ` $display ` is
true, true otherwise.

##  Source

    
    
    public function print_extra_script( $handle, $display = true ) {
    	$output = $this->get_data( $handle, 'data' );
    	if ( ! $output ) {
    		return;
    	}
    
    	if ( ! $display ) {
    		return $output;
    	}
    
    	wp_print_inline_script_tag( $output, array( 'id' => "{$handle}-js-extra" ) );
    
    	return true;
    }
    

[ View all references ](https://developer.wordpress.org/reference/files/wp-
includes_class-wp-scripts-php-2/) [ View on Trac
](https://core.trac.wordpress.org/browser/tags/6.5/src/wp-includes/class-wp-
scripts.php#L219) [ View on GitHub ](https://github.com/WordPress/wordpress-
develop/blob/6.5/src/wp-includes/class-wp-scripts.php#L219-L232)

##  Related

Uses  |  Description   
---|---  
[ 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.   
Used by  |  Description   
---|---  
[ WP_Scripts::print_scripts_l10n() ](https://developer.wordpress.org/reference/classes/wp_scripts/print_scripts_l10n/) ` wp-includes/class-wp-scripts.php