# wp_preload_resources

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

Тип: хук-фильтр.
Появился в версии: 6.1.0.

## Сигнатура

```php
apply_filters( 'wp_preload_resources', array $preload_resources )
```

## Описание

Фильтрует домены и URL-адреса для предзагрузки ресурсов.

## Параметры

- `$preload_resources` `array` — обязательный. Массив ресурсов и их атрибутов либо URL-адресов для вывода предзагрузки ресурсов.
  
  ...$0 array Массив атрибутов ресурса.
  href stringURL для включения в предзагрузку ресурсов. Обязательный.
  
  as stringКак браузер должен обрабатывать ресурс (script, style, image, document и т.д.).
  
  crossorigin stringУказывает политику CORS для заданного ресурса.
  
  type stringТип ресурса (text/html, text/css и т.д.).
  
  media stringПринимает типы носителей или медиазапросы. Позволяет адаптивную предзагрузку.
  
  imagesizes stringАдаптивный размер источника для source set.
  
  imagesrcset stringАдаптивные источники изображений для source set.
  
  fetchpriority stringЗначение fetchpriority для ресурса.
  
  Source $preload_resources = apply_filters( 'wp_preload_resources', array() );
  View all references View on Trac View on GitHub
  
  Related Used byDescriptionwp_preload_resources()wp-includes/general-template.phpВыводит директивы предзагрузки ресурсов в браузеры.
  
  Changelog VersionDescription6.6.0Added the $fetchpriority attribute.6.1.0Introduced.
  User Contributed Notes
  
  Skip to note 2 content
  
  Robert C.
  
  2 years ago
  
  You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
  
  Вот как можно использовать фильтр wp_preload_resources для предзагрузки стилей вашей темы.
  
  function craftedat_preload_assets( array $preload_resources ): array {
  
  /**
  * Check if stylesheet is loaded.
  * 'theme-style' is the WP handle of your stylesheet.
  */
  if ( wp_style_is( 'theme-style' ) ) {
  $wp_style_theme = wp_styles()->registered['theme-style'];
  
  // Including the version number is crucial.
  $path_to_theme_styles = $wp_style_theme->src . '?ver=' . $wp_style_theme->ver;
  
  $preload_resources[] = array(
  'href' => $path_to_theme_styles,
  'as' => 'style',
  'media' => 'all',
  'type' => 'text/css',
  );
  }
  
  return $preload_resources;
  }
  
  add_filter( 'wp_preload_resources', 'craftedat_preload_assets' );
  
  Log in to add feedback

## Фильтруемое значение

Массив ресурсов и их атрибутов либо URL-адресов для вывода предзагрузки ресурсов.

...$0 array Массив атрибутов ресурса.
href stringURL для включения в предзагрузку ресурсов. Обязательный.

as stringКак браузер должен обрабатывать ресурс (script, style, image, document и т.д.).

crossorigin stringУказывает политику CORS для заданного ресурса.

type stringТип ресурса (text/html, text/css и т.д.).

media stringПринимает типы носителей или медиазапросы. Позволяет адаптивную предзагрузку.

imagesizes stringАдаптивный размер источника для source set.

imagesrcset stringАдаптивные источники изображений для source set.

fetchpriority stringЗначение fetchpriority для ресурса.

Source $preload_resources = apply_filters( 'wp_preload_resources', array() );
View all references View on Trac View on GitHub

Related Used byDescriptionwp_preload_resources()wp-includes/general-template.phpВыводит директивы предзагрузки ресурсов в браузеры.

Changelog VersionDescription6.6.0Added the $fetchpriority attribute.6.1.0Introduced.
User Contributed Notes

Skip to note 2 content

Robert C.

2 years ago

You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

Вот как можно использовать фильтр wp_preload_resources для предзагрузки стилей вашей темы.

function craftedat_preload_assets( array $preload_resources ): array {

/**
* Check if stylesheet is loaded.
* 'theme-style' is the WP handle of your stylesheet.
*/
if ( wp_style_is( 'theme-style' ) ) {
$wp_style_theme = wp_styles()->registered['theme-style'];

// Including the version number is crucial.
$path_to_theme_styles = $wp_style_theme->src . '?ver=' . $wp_style_theme->ver;

$preload_resources[] = array(
'href' => $path_to_theme_styles,
'as' => 'style',
'media' => 'all',
'type' => 'text/css',
);
}

return $preload_resources;
}

add_filter( 'wp_preload_resources', 'craftedat_preload_assets' );

Log in to add feedback

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

Файл: `wp-includes/general-template.php:3787`

```php
$preload_resources = apply_filters( 'wp_preload_resources', array() );
```

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

- 6.6.0 — Added the $fetchpriority attribute.
- 6.1.0 — Introduced.

## Связанные

Используется в: [`wp_preload_resources`](https://chugunov.pro/api-wordpress/functions/wp_preload_resources/).

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