Title: wp_preload_resources
Published: November 2, 2022
Last modified: February 24, 2026

---

# apply_filters( ‘wp_preload_resources’, array $preload_resources )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#user-contributed-notes)

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

Filters domains and URLs for resource preloads.

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

 `$preload_resources`array

Array of resources and their attributes, or URLs to print for resource preloads.

 * `...$0` array
 *  Array of resource attributes.
    - `href` string
    - URL to include in resource preloads. Required.
    - `as` string
    - How the browser should treat the resource (`script`, `style`, `image`, `document`,
      etc).
    - `crossorigin` string
    - Indicates the CORS policy of the specified resource.
    - `type` string
    - Type of the resource (`text/html`, `text/css`, etc).
    - `media` string
    - Accepts media types or media queries. Allows responsive preloading.
    - `imagesizes` string
    - Responsive source size to the source Set.
    - `imagesrcset` string
    - Responsive image sources to the source set.
    - `fetchpriority` string
    - Fetchpriority value for the resource.

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

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

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

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

| Used by | Description | 
| [wp_preload_resources()](https://developer.wordpress.org/reference/functions/wp_preload_resources/)`wp-includes/general-template.php` |

Prints resource preloads directives to browsers.

  |

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

| Version | Description | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Added the `$fetchpriority` attribute. | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/wp_preload_resources/?output_format=md#comment-content-6930)
 2.   [Robert C.](https://profiles.wordpress.org/rawbird/)  [  2 years ago  ](https://developer.wordpress.org/reference/hooks/wp_preload_resources/#comment-6930)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_preload_resources%2F%23comment-6930)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_preload_resources%2F%23comment-6930)
 4. This is how you could use the `wp_preload_resources` filter to **preload your theme
    styles**.
 5.     ```php
        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' );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_preload_resources%2F%3Freplytocom%3D6930%23feedback-editor-6930)

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