diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
index 2bcdb43..6d0fdd8 100644
--- src/wp-includes/general-template.php
+++ src/wp-includes/general-template.php
@@ -2799,8 +2799,14 @@ function wp_site_icon() {
  */
 function wp_resource_hints() {
 	$hints = array(
-		'dns-prefetch' => wp_resource_hints_scripts_styles(),
-		'preconnect'   => array( 's.w.org' ),
+		'dns-prefetch' => wp_dependencies_unique_hosts(),
+		'preconnect'   => array(
+			// Loop below will trim URLs to host only.
+			/** This filter is documented in wp-includes/formatting.php */
+			apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/72x72/' ),
+			/** This filter is documented in wp-includes/formatting.php */
+			apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/svg/' ),
+		),
 		'prefetch'     => array(),
 		'prerender'    => array(),
 	);
@@ -2851,31 +2857,27 @@ function wp_resource_hints() {
 }
 
 /**
- * Adds dns-prefetch for all scripts and styles enqueued from external hosts.
+ * Returns a list of unique hosts of all enqueued scripts and styles.
  *
  * @since 4.6.0
+ *
+ * @return array A list of unique hosts of enqueued scripts and styles.
  */
-function wp_resource_hints_scripts_styles() {
+function wp_dependencies_unique_hosts() {
 	global $wp_scripts, $wp_styles;
 
 	$unique_hosts = array();
 
-	if ( is_object( $wp_scripts ) && ! empty( $wp_scripts->registered ) ) {
-		foreach ( $wp_scripts->registered as $registered_script ) {
-			$parsed = wp_parse_url( $registered_script->src );
+	foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) {
+		if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) {
+			foreach ( $dependencies->queue as $handle ) {
+				/* @var _WP_Dependency $dependency */
+				$dependency = $dependencies->registered[ $handle ];
+				$parsed     = wp_parse_url( $dependency->src );
 
-			if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
-				$unique_hosts[] = $parsed['host'];
-			}
-		}
-	}
-
-	if ( is_object( $wp_styles ) && ! empty( $wp_styles->registered ) ) {
-		foreach ( $wp_styles->registered as $registered_style ) {
-			$parsed = wp_parse_url( $registered_style->src );
-
-			if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
-				$unique_hosts[] = $parsed['host'];
+				if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
+					$unique_hosts[] = $parsed['host'];
+				}
 			}
 		}
 	}
diff --git tests/phpunit/tests/general/resourceHints.php tests/phpunit/tests/general/resourceHints.php
index 7041a61..c7fb227 100644
--- tests/phpunit/tests/general/resourceHints.php
+++ tests/phpunit/tests/general/resourceHints.php
@@ -31,7 +31,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 	}
 
 	function test_should_have_defaults_on_frontend() {
-		$expected = "<link rel='preconnect' href='http://s.w.org'>\n";
+		$expected = "<link rel='preconnect' href='https://s.w.org'>\n";
 
 		$this->expectOutputString( $expected );
 
@@ -42,7 +42,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 		$expected = "<link rel='dns-prefetch' href='//wordpress.org'>\n" .
 					"<link rel='dns-prefetch' href='//google.com'>\n" .
 					"<link rel='dns-prefetch' href='//make.wordpress.org'>\n" .
-					"<link rel='preconnect' href='http://s.w.org'>\n";
+					"<link rel='preconnect' href='https://s.w.org'>\n";
 
 		add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ), 10, 2 );
 
@@ -67,7 +67,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 	}
 
 	function test_prerender() {
-		$expected = "<link rel='preconnect' href='http://s.w.org'>\n" .
+		$expected = "<link rel='preconnect' href='https://s.w.org'>\n" .
 					"<link rel='prerender' href='https://make.wordpress.org/great-again'>\n" .
 					"<link rel='prerender' href='http://jobs.wordpress.net'>\n" .
 					"<link rel='prerender' href='//core.trac.wordpress.org'>\n";
@@ -94,7 +94,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 
 	function test_parse_url_dns_prefetch() {
 		$expected = "<link rel='dns-prefetch' href='//make.wordpress.org'>\n" .
-					"<link rel='preconnect' href='http://s.w.org'>\n";
+					"<link rel='preconnect' href='https://s.w.org'>\n";
 
 		add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ), 10, 2 );
 
@@ -115,7 +115,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 
 	function test_dns_prefetch_styles() {
 		$expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com'>\n" .
-					"<link rel='preconnect' href='http://s.w.org'>\n";
+					"<link rel='preconnect' href='https://s.w.org'>\n";
 
 		$args = array(
 			'family' => 'Open+Sans:400',
@@ -134,7 +134,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 
 	function test_dns_prefetch_scripts() {
 		$expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com'>\n" .
-					"<link rel='preconnect' href='http://s.w.org'>\n";
+					"<link rel='preconnect' href='https://s.w.org'>\n";
 
 		$args = array(
 			'family' => 'Open+Sans:400',
@@ -150,4 +150,17 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase {
 		$this->assertEquals( $expected, $actual );
 	}
 
+	function test_dns_prefetch_scripts_does_not_included_registered_only() {
+		$expected = "<link rel='preconnect' href='https://s.w.org'>\n";
+		$unexpected = "<link rel='dns-prefetch' href='//wordpress.org'>\n";
+
+		wp_register_script( 'jquery-elsewhere', 'https://wordpress.org/wp-includes/js/jquery/jquery.js' );
+
+		$actual = get_echo( 'wp_resource_hints' );
+
+		wp_deregister_script( 'jquery-elsewhere' );
+
+		$this->assertEquals( $expected, $actual );
+		$this->assertNotContains( $unexpected, $actual );
+	}
 }
