wp_preload_resources filter-hookWP 6.1.0

Filters domains and URLs for resource preloads.

Usage

add_filter( 'wp_preload_resources', 'wp_kama_preload_resources_filter' );

/**
 * Function for `wp_preload_resources` filter-hook.
 * 
 * @param array $preload_resources Array of resources and their attributes, or URLs to print for resource preloads.
 *
 * @return array
 */
function wp_kama_preload_resources_filter( $preload_resources ){

	// filter...
	return $preload_resources;
}
$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.

Changelog

Since 6.1.0 Introduced.

Where the hook is called

wp_preload_resources()
wp_preload_resources
wp-includes/general-template.php 3602
$preload_resources = apply_filters( 'wp_preload_resources', array() );

Where the hook is used in WordPress

Usage not found.