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
随机推荐
- talk is cheap, show me the code——dcgan,wgan,wgan-gp的tensorflow实现
最近学习了生成对抗网络(GAN),基于几个经典GAN网络结构做了些小实验,包括dcgan,wgan,wgan-gp.坦率的说,wgan,wgan-gp论文的原理还是有点小复杂,我也没有完全看明白,因此 ...
- [Python] 00 - Books
A.I. & Optimization Advanced Machine Learning, Data Mining, and Online Advertising Services Ref: ...
- 理解Generic.xaml和Themes
"Generic.xaml"这个名称并非偶然 通过上面的叙述,你可能会有冲动将Generic.xaml中的Style代码剪切出来,粘贴到任何一个我们的控件可以找到的地方,然后把Ge ...
- 【class2src】Decompiler
方法源自:https://stackoverflow.com/questions/272535/how-do-i-decompile-java-class-files 功能:给定一个.class文件, ...
- 图表统计FusionCharts
工作中用的图形统计,用的FusionCharts,发现Chenssy总结了很详细了,特此记录一下.tks Chenssy. tks: http://www.cnblogs.com/chenssy/ar ...
- NIO相关概念之Selector
选择器(selector): 选择器管理者一个被注册的通道的集合信息和它们的就绪状态.通道是和选择器一起被注册的,并且使用选择器来更新通道的就绪状态,当这么做的时候,可以选择被激发的线程挂起,直到有就 ...
- day_5.19 py总结②
- 新版谷歌浏览器怎么查找和改变编码格式 IT开发人员谷歌的编码格式
解决方法在最下面,还有可下载的安装包 今天,无意中在解决一个乱码问题,后台是有过判断解决兼容性问题,但是有个别电脑还是有乱码问题,就去想改变下前台的编码格式,突然发现一向好用的谷歌,居然找不到编码格式 ...
- You are using pip version 9.0.1, however version 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
实测使用pip3进行一些软件安装的时候,会弹出这个,记住不要理会,一旦你执行,就会升级pip,并冲突pip3造成pip3不能用,这时候就要重新安装一下python3
- hbase运行mapreduce设置及基本数据加载方法
hbase与mapreduce集成后,运行mapreduce程序,同时需要mapreduce jar和hbase jar文件的支持,这时我们需要通过特殊设置使任务可以同时读取到hadoop jar和h ...