# wp_enqueue_script()

URL: https://chugunov.pro/api-wordpress/functions/wp_enqueue_script/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.1.0.

## Сигнатура

```php
wp_enqueue_script( string $handle, string $src = '', string[] $deps = array(), string|bool|null $ver = false, array|bool $args = array() )
```

## Описание

Registers the script if `$src` provided (does NOT overwrite), and enqueues it.[See also](#see-also)
- [WP_Dependencies::add()](https://developer.wordpress.org/reference/classes/WP_Dependencies/add/)

- [WP_Dependencies::add_data()](https://developer.wordpress.org/reference/classes/WP_Dependencies/add_data/)

- [WP_Dependencies::enqueue()](https://developer.wordpress.org/reference/classes/WP_Dependencies/enqueue/)

## Параметры

- `$handle` `string` — обязательный. Имя скрипта. Должно быть уникальным.
- `$src` `string` — необязательный, по умолчанию `''`. Полный URL скрипта или путь к скрипту относительно корневого каталога WordPress.
- `$deps` `string[]` — необязательный, по умолчанию `array()`. Массив дескрипторов зарегистрированных скриптов, от которых зависит этот скрипт.
- `$ver` `string|bool|null` — необязательный, по умолчанию `false`. Строка, задающая номер версии скрипта, если он есть; она добавляется к URL в виде строки запроса для сброса кэша. Если version установлен в false, автоматически добавляется номер версии, равный текущей установленной версии WordPress.
  
  Если установлено null, версия не добавляется.
- `$args` `array|bool` — необязательный, по умолчанию `array()`. Массив дополнительных аргументов для скрипта.
  
  Иначе это может быть логическое значение, которое определяет, печатается ли скрипт в подвале. По умолчанию false.
  
  strategy stringНеобязательный. Если задан, может быть 'defer' или 'async'.
  
  in_footer boolНеобязательный. Печатать ли скрипт в подвале. По умолчанию 'false'.
  
  fetchpriority stringНеобязательный. Приоритет загрузки скрипта. По умолчанию 'auto'.
  
  module_dependencies arrayНеобязательный. Идентификаторы зависимостей-модулей, загружаемых через динамический импорт.
  
  Полный формат данных смотрите в параметре $deps функции wp_register_script_module().
  
  Если он задан, скрипт должен либо печататься в подвале (с in_footer, установленным в true), либо использовать стратегию отложенной загрузки (defer), чтобы карта импорта модулей скрипта печаталась до выполнения скрипта. Иначе динамические импорты могут не разрешиться.

## Исходный код

Файл: `wp-includes/functions-wp-scripts.php:473`

```php
function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $args = array() ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

	$wp_scripts = wp_scripts();

	if ( $src || ! empty( $args ) ) {
		/** @var array{ 0: non-empty-string, 1?: string } $_handle */
		$_handle = explode( '?', $handle );
		if ( ! is_array( $args ) ) {
			$args = array(
				'in_footer' => (bool) $args,
			);
		}

		if ( $src ) {
			$wp_scripts->add( $_handle[0], $src, $deps, $ver );
		}
		if ( ! empty( $args ) ) {
			_wp_scripts_add_args_data( $wp_scripts, $_handle[0], $args );
		}
	}

	$wp_scripts->enqueue( $handle );
}
```

## История изменений

- 7.0.0 — The $module_dependencies parameter of type string[] was added to the $args parameter of type array.
- 6.9.0 — The $fetchpriority parameter of type string was added to the $args parameter of type array.
- 6.3.0 — The $in_footer parameter of type boolean was overloaded to be an $args parameter of type array.
- 2.1.0 — Introduced.

## Связанные

Использует: [`wp_scripts`](https://chugunov.pro/api-wordpress/functions/wp_scripts/).
Используется в: [`wp_options_connectors_wp_admin_enqueue_scripts`](https://chugunov.pro/api-wordpress/functions/wp_options_connectors_wp_admin_enqueue_scripts/), [`wp_options_connectors_render_page`](https://chugunov.pro/api-wordpress/functions/wp_options_connectors_render_page/), [`wp_font_library_render_page`](https://chugunov.pro/api-wordpress/functions/wp_font_library_render_page/), [`wp_font_library_wp_admin_enqueue_scripts`](https://chugunov.pro/api-wordpress/functions/wp_font_library_wp_admin_enqueue_scripts/), [`wp_enqueue_command_palette_assets`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_command_palette_assets/), [`_wp_get_iframed_editor_assets`](https://chugunov.pro/api-wordpress/functions/_wp_get_iframed_editor_assets/), [`wp_maybe_enqueue_oembed_host_js`](https://chugunov.pro/api-wordpress/functions/wp_maybe_enqueue_oembed_host_js/), [`wp_enqueue_editor_format_library_assets`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_editor_format_library_assets/), `WP_Block::render`, [`wp_enqueue_editor_block_directory_assets`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_editor_block_directory_assets/), [`enqueue_editor_block_styles_assets`](https://chugunov.pro/api-wordpress/functions/enqueue_editor_block_styles_assets/), [`wp_enqueue_registered_block_scripts_and_styles`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_registered_block_scripts_and_styles/), [`the_block_editor_meta_boxes`](https://chugunov.pro/api-wordpress/functions/the_block_editor_meta_boxes/), [`register_and_do_post_meta_boxes`](https://chugunov.pro/api-wordpress/functions/register_and_do_post_meta_boxes/), `WP_Privacy_Policy_Content::notice`, [`wp_enqueue_code_editor`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_code_editor/), `WP_Widget_Media_Gallery::enqueue_admin_scripts`, `WP_Widget_Custom_HTML::enqueue_admin_scripts`, `WP_Widget_Text::enqueue_admin_scripts`, `WP_Widget_Media_Audio::enqueue_admin_scripts`, `WP_Widget_Media_Audio::enqueue_preview_scripts`, `WP_Widget_Media_Video::enqueue_preview_scripts`, `WP_Widget_Media_Video::enqueue_admin_scripts`, `WP_Widget_Media::enqueue_admin_scripts`, `WP_Widget_Media_Image::enqueue_admin_scripts`, [`the_custom_header_markup`](https://chugunov.pro/api-wordpress/functions/the_custom_header_markup/), `WP_Customize_Selective_Refresh::enqueue_preview_scripts`, `WP_Customize_Cropped_Image_Control::enqueue`, `WP_Customize_Nav_Menus::customize_preview_enqueue_deps`, `WP_Customize_Nav_Menus::enqueue_scripts`, [`wp_dashboard_setup`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_setup/), `WP_Internal_Pointers::enqueue_scripts`, [`do_accordion_sections`](https://chugunov.pro/api-wordpress/functions/do_accordion_sections/), [`wp_media_upload_handler`](https://chugunov.pro/api-wordpress/functions/wp_media_upload_handler/), [`media_upload_gallery`](https://chugunov.pro/api-wordpress/functions/media_upload_gallery/), [`enqueue_comment_hotkeys_js`](https://chugunov.pro/api-wordpress/functions/enqueue_comment_hotkeys_js/), `Custom_Image_Header::js_includes`, `Custom_Background::admin_load`, `WP_Customize_Manager::enqueue_control_scripts`, `WP_Customize_Manager::customize_preview_init`.

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_enqueue_script/
