wp_preload_resources

过滤钩子
apply_filters( 'wp_preload_resources', array()
参数
  • (array) $preload_resources { Array of resources and their attributes, or URLs to print for resource preloads. @type array ...$0 { Array of resource attributes. @type string $href URL to include in resource preloads. Required. @type string $as How the browser should treat the resource (`script`, `style`, `image`, `document`, etc). @type string $crossorigin Indicates the CORS policy of the specified resource. @type string $type Type of the resource (`text/html`, `text/css`, etc). @type string $media Accepts media types or media queries. Allows responsive preloading. @type string $imagesizes Responsive source size to the source Set. @type string $imagesrcset Responsive image sources to the source set. } }
    Required:
定义位置
相关勾子
wp_resource_hintswp_refresh_nonceswp_prepare_revision_for_jswp_headerswp_redirect
相关方法
wp_preload_resourceswp_preload_dialogswp_resource_hintswp_remote_requestrest_preload_api_requestwp_load_press_this
引入
6.1.0
弃用
-

wp_preload_resources: 这是一个钩子(hook),用于预加载WordPress页面上的资源,例如图像和样式表。通过使用此钩子,插件和主题开发者可以指定预加载的资源,以提高页面的加载速度。

为资源预加载过滤域和URL。

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

常见问题

FAQs
查看更多 >