wp_resource_hints WordPress Filter Hook

The wp_resource_hints hook allows you to modify the dns-prefetch, preconnect, and prefetch resource hints for your website. This can be useful for improving the performance of your website by making sure that the necessary resources are loaded before they are needed.

apply_filters( 'wp_resource_hints', array $urls, string $relation_type ) #

Filters domains and URLs for resource hints of relation type.


Parameters

$urls

(array)Array of resources and their attributes, or URLs to print for resource hints.

  • '...$0'
    (array|string) Array of resource attributes, or a URL string.
    • 'href'
      (string) URL to include in resource hints. 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.
    • 'pr'
      (float) Expected probability that the resource hint will be used.
    • 'type'
      (string) Type of the resource (text/html, text/css, etc).

$relation_type

(string)The relation type the URLs are printed for, e.g. 'preconnect' or 'prerender'.


Top ↑

Source

File: wp-includes/general-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.7.0The $urls parameter accepts arrays of specific HTML attributes as its child elements.
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More