Make WordPress Core

Changeset 57789

Timestamp:
03/07/2024 07:06:53 AM (5 months ago)
Author:
adamsilverstein
Message:

Script loader: enable fetchpriority attribute in the wp_preload_resources filter.

Add fetchpriority to the attributes accepted by the wp_preload_resources filter. Developers can now use this filter to set fetchpriority for resources being preloaded.

Props nihar007, luboslives, tabrisrp.
Fixes #58510.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r57644 r57789  
    35803580     *
    35813581     * @since 6.1.0
     3582
    35823583     *
    35833584     * @param array  $preload_resources {
     
    35873588     *         Array of resource attributes.
    35883589     *
    3589      *         @type string $href        URL to include in resource preloads. Required.
    3590      *         @type string $as          How the browser should treat the resource
    3591      *                                   (`script`, `style`, `image`, `document`, etc).
    3592      *         @type string $crossorigin Indicates the CORS policy of the specified resource.
    3593      *         @type string $type        Type of the resource (`text/html`, `text/css`, etc).
    3594      *         @type string $media       Accepts media types or media queries. Allows responsive preloading.
    3595      *         @type string $imagesizes  Responsive source size to the source Set.
    3596      *         @type string $imagesrcset Responsive image sources to the source set.
     3590     *         @type string $href          URL to include in resource preloads. Required.
     3591     *         @type string $as            How the browser should treat the resource
     3592     *                                     (`script`, `style`, `image`, `document`, etc).
     3593     *         @type string $crossorigin   Indicates the CORS policy of the specified resource.
     3594     *         @type string $type          Type of the resource (`text/html`, `text/css`, etc).
     3595     *         @type string $media         Accepts media types or media queries. Allows responsive preloading.
     3596     *         @type string $imagesizes    Responsive source size to the source Set.
     3597     *         @type string $imagesrcset   Responsive image sources to the source set.
     3598     *         @type string $fetchpriority Fetchpriority value for the resource.
    35973599     *     }
    35983600     * }
     
    36423644
    36433645            // Ignore non-supported attributes.
    3644             $non_supported_attributes = array( 'as', 'crossorigin', 'href', 'imagesrcset', 'imagesizes', 'type', 'media' );
     3646            $non_supported_attributes = array( 'as', 'crossorigin', 'href', 'imagesrcset', 'imagesizes', 'type', 'media' );
    36453647            if ( ! in_array( $resource_key, $non_supported_attributes, true ) && ! is_numeric( $resource_key ) ) {
    36463648                continue;
  • trunk/tests/phpunit/tests/general/wpPreloadResources.php

    r56547 r57789  
    248248                ),
    249249            ),
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
    250260        );
    251261    }
Note: See TracChangeset for help on using the changeset viewer.