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
NSThread.NSOperation.GCD 总结: 无论使用哪种方法进行多线程开发,每个线程启动后并不一定立即执行相应的操作,具体什么时候由系统调度(CPU 空闲时就会执行) 更新 UI 应该在 ...
- 小程序渲染html的两种方法
一.使用文档自带的原生API rich-text, nodes属性直接绑定需要渲染的html内容即可,文档参见这里:https://developers.weixin.qq.com/miniprog ...
- SSM框架搭建最新教程(超详细)
个人认为使用框架并不是很难,关键要理解其思想,这对于我们提高编程水平很有帮助.不过,如果用都不会,谈思想就变成纸上谈兵了!!!先技术,再思想.实践出真知. 1.基本概念 1.1.Spring Spr ...
- [PyData] 03 - Data Representation
Ref: http://blog.csdn.net/u013534498/article/details/51399035 如何在Python中实现这五类强大的概率分布 考虑下在mgrid上画二维概率 ...
- 路由查询命令tracert
from:https://jingyan.baidu.com/article/9c69d48f4df25713c8024e66.html 在命令行中输入“tracert ”并在后面加入一个IP地址,可 ...
- 修改Ubuntu的aptget源为阿里源的方法
1.复制原文件备份sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 2.编辑源列表文件 sudo vim /etc/apt/sources ...
- [原]openstack-kilo--issue(十二)openstack-keystone和httpd服务同时占用35357和5000
本博客已经添加"打赏"功能,"打赏"位置位于右边栏红色框中,感谢您赞助的咖啡. == Keystone service == openstack-keyston ...
- MVC的ViewData自动给Razor写的input赋值
问题: 写编辑的时候,突然发现,没有值的model,突然出现了值,而且值是ViewData中值. 后台: this.ViewData["test"] = "测试" ...
- 也谈.Net中间语言——破解Delphi2CS行数和时间限制
其实我一直在研究将Delphi版的传奇2源代码使用C#实现,不过由于我并没有学习过Delphi.就只能说先试着用一些工具转换代码. 后来我在网上找到了一款软件:Delphi2CS.这款软件比较强大,虽 ...
- FIFO设计中的深度计算【zz】
FIFO设计中的深度计算: 写时钟频率 w_clk, 读时钟频率 r_clk, 写时钟周期里,每B个时钟周期会有A个数据写入FIFO: 读时钟周期里,每Y个时钟周期会有X个数据读出FIFO: 则,FI ...