Make WordPress Core


Ignore:
Timestamp:
07/19/2016 02:34:42 AM (8 years ago)
Author:
peterwilsoncc
Message:

Script Loader: Limit resource hinting to enqueued assets.

Externally hosted script and style dependencies trigger dns-prefetch hinting only when enqueued. This removed a bug in which hinting was added on registration.

Renames the function wp_resource_hints_scripts_styles to wp_dependencies_unique_hosts as the function provides the hosts, not the hinting.

Props swissspidy.
Fixes #37385.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/resourceHints.php

    r38036 r38100  
    151151    }
    152152
     153    function test_dns_prefetch_scripts_does_not_included_registered_only() {
     154        $expected = "<link rel='preconnect' href='http://s.w.org'>\n";
     155        $unexpected = "<link rel='dns-prefetch' href='//wordpress.org'>\n";
     156
     157        wp_register_script( 'jquery-elsewhere', 'https://wordpress.org/wp-includes/js/jquery/jquery.js' );
     158
     159        $actual = get_echo( 'wp_resource_hints' );
     160
     161        wp_deregister_script( 'jquery-elsewhere' );
     162
     163        $this->assertEquals( $expected, $actual );
     164        $this->assertNotContains( $unexpected, $actual );
     165    }
    153166}
Note: See TracChangeset for help on using the changeset viewer.