wordpress去掉<link rel='dns-prefetch' href='//s.w.org' />
我们在用wordpress建站时经常会看到<link rel='dns-prefetch' href='//s.w.org' />,应该是为了从s.w.org预获取表情和头像,目的是提高网页加载速度 ,但s.w.org国内根本无法访问,怎么把这个东西去掉呢?有几种方法:
1、在主题function.php文件中屏蔽
remove_action( 'wp_head', 'wp_resource_hints', 2 );
或者下面这种改造过的方法,兼容性会好点
function remove_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}
return $hints;
}
add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
2、直接在文件去除相关函数,/wp-includes/general-template.php大概2903行全部注释
// foreach ( $urls as $key => $url ) {
// $atts = array();
//
// if ( is_array( $url ) ) {
// if ( isset( $url['href'] ) ) {
// $atts = $url;
// $url = $url['href'];
// } else {
// continue;
// }
// }
//
// $url = esc_url( $url, array( 'http', 'https' ) );
//
// if ( ! $url ) {
// continue;
// }
//
// if ( isset( $unique_urls[ $url ] ) ) {
// continue;
// }
//
// if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) {
// $parsed = wp_parse_url( $url );
//
// if ( empty( $parsed['host'] ) ) {
// continue;
// }
//
// if ( 'preconnect' === $relation_type && ! empty( $parsed['scheme'] ) ) {
// $url = $parsed['scheme'] . '://' . $parsed['host'];
// } else {
// // Use protocol-relative URLs for dns-prefetch or if scheme is missing.
// $url = '//' . $parsed['host'];
// }
// }
//
// $atts['rel'] = $relation_type;
// $atts['href'] = $url;
//
// $unique_urls[ $url ] = $atts;
// }
wordpress去掉<link rel='dns-prefetch' href='//s.w.org' />的更多相关文章
- <link rel="shortcut icon" href="Xubuntu.ico" type="image/x-icon" /> <LINK href="Xubuntu.ico" rel="shortcut icon"> <link href="Xubuntu.ico" rel="B
<link rel="shortcut icon" href="Xubuntu.ico" type="image/x-icon" /& ...
- 使用link rel="shortcut icon"为网页标题加图标
<title>会员卡券</title> <link rel="shortcut icon" href="http://GT/img/favi ...
- <link rel="stylesheet" href="3.css"/> 链接方式
<link rel="stylesheet" href="3.css"/> <!doctype html> <html> & ...
- DNS Prefetch
DNS 实现域名到IP的映射.通过域名访问站点,每次请求都要做DNS解析.目前每次DNS解析,通常在200ms以下.针对DNS解析耗时问题,一些浏览器通过DNS Prefetch 来提高访问的流畅性. ...
- DNS Prefetch初认识
今天在看一个后台框架时,发现这样的代码: <link rel="dns-prefetch" href="//0.s3.envato.com">< ...
- 浏览器 DNS缓存与DNS prefetch (DNS预解析)
浏览器 DNS缓存 浏览器DNS缓存的时间跟DNS服务器返回的TTL值无关. 注:TTL(Time-To-Live),就是一条域名解析记录在DNS服务器中的存留时间. 浏览器在获取网站域名的实际IP地 ...
- DNS Prefetch 【DNS 预解析技术】
DNS 实现域名到IP的映射.通过域名访问站点,每次请求都要做DNS解析.目前每次DNS解析,通常在200ms以下.针对DNS解析耗时问题,一些浏览器通过DNS Prefetch 来提高访问的流畅性. ...
- WordPress 去掉底部的自豪的采用WordPress
WordPress 去掉底部的自豪的采用WordPress
- WordPress 去掉功能中的 wordpress.org
WordPress 去掉功能中的 wordpress.org
随机推荐
- 使用 GCD 实现倒计时效果
效果如下: ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @p ...
- golang IO 流抽象与应用
https://blog.csdn.net/pmlpml/article/details/82930191
- 百度网盘上下载文件,调用api接口的请求方式和参数
REST api 功能:下载单个文件. Download接口支持HTTP协议标准range定义,通过指定range的取值可以实现断点下载功能. 例如: 如果在request消息中指定“Range: b ...
- iOS手机淘宝加入购物车动画分析
本文转载至 http://www.jianshu.com/p/e77e3ce8ee24 1.最终效果 仿淘宝动画 2.核心代码 _cartAnimView=[[UIImageView alloc] i ...
- 带分数|2013年蓝桥杯B组题解析第九题-fishers
带分数 100 可以表示为带分数的形式:100 = 3 + 69258 / 714 还可以表示为:100 = 82 + 3546 / 197 注意特征:带分数中,数字1~9分别出现且只出现一次(不包含 ...
- Understanding Flash: Blocks, Pages and Program / Erases
https://flashdba.com/2014/06/20/understanding-flash-blocks-pages-and-program-erases/ In the last pos ...
- 洛谷P1182 数列分段【二分】【贪心】
题目:https://www.luogu.org/problemnew/show/P1182 题意: 有n个数,要分成连续的m段.将每段中的数相加,问之和的最大值的最小值是多少. 思路: 和P1316 ...
- 基于微服务架构、运行于容器中的.NET Core示例应用eShopOnContainers
eShopOnContainers 是 <.NET Microservices – Architecture for Containerized .NET Applications>这本微 ...
- tar命令参数详解
命令总览:tar [-]A --catenate --concatenate | c --create | d --diff --compare | r --append | t --list | u ...
- PHP微信支付开发
此链接https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_2,是微信官方的示例,无效,报错. 1.申请微信支付的开通条件?什么样的账号可以 ...