Skip to content

Commit

Permalink
Twenty Sixteen: Add pre-connect resource hint for Google Fonts.
Browse files Browse the repository at this point in the history
When using Google Fonts, pre-connect to https://fonts.gstatic.com to improve the performance downloading the webfont files.

Props westonruter.
Fixes #44668.

Built from https://develop.svn.wordpress.org/trunk@43606


git-svn-id: http://core.svn.wordpress.org/trunk@43435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
peterwilsoncc committed Sep 3, 2018
1 parent 70e66a0 commit b8bf6de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions wp-content/themes/twentysixteen/functions.php
Expand Up @@ -155,6 +155,27 @@ function twentysixteen_content_width() {
}
add_action( 'after_setup_theme', 'twentysixteen_content_width', 0 );

/**
* Add preconnect for Google Fonts.
*
* @since Twenty Sixteen 1.6
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array $urls URLs to print for resource hints.
*/
function twentysixteen_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'twentysixteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin',
);
}

return $urls;
}
add_filter( 'wp_resource_hints', 'twentysixteen_resource_hints', 10, 2 );

/**
* Registers a widget area.
*
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-43605';
$wp_version = '5.0-alpha-43606';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit b8bf6de

Please sign in to comment.