我们在用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' />的更多相关文章

  1. <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" /& ...

  2. 使用link rel="shortcut icon"为网页标题加图标

    <title>会员卡券</title> <link rel="shortcut icon" href="http://GT/img/favi ...

  3. <link rel="stylesheet" href="3.css"/> 链接方式

    <link rel="stylesheet" href="3.css"/> <!doctype html> <html> & ...

  4. DNS Prefetch

    DNS 实现域名到IP的映射.通过域名访问站点,每次请求都要做DNS解析.目前每次DNS解析,通常在200ms以下.针对DNS解析耗时问题,一些浏览器通过DNS Prefetch 来提高访问的流畅性. ...

  5. DNS Prefetch初认识

    今天在看一个后台框架时,发现这样的代码: <link rel="dns-prefetch" href="//0.s3.envato.com">< ...

  6. 浏览器 DNS缓存与DNS prefetch (DNS预解析)

    浏览器 DNS缓存 浏览器DNS缓存的时间跟DNS服务器返回的TTL值无关. 注:TTL(Time-To-Live),就是一条域名解析记录在DNS服务器中的存留时间. 浏览器在获取网站域名的实际IP地 ...

  7. DNS Prefetch 【DNS 预解析技术】

    DNS 实现域名到IP的映射.通过域名访问站点,每次请求都要做DNS解析.目前每次DNS解析,通常在200ms以下.针对DNS解析耗时问题,一些浏览器通过DNS Prefetch 来提高访问的流畅性. ...

  8. WordPress 去掉底部的自豪的采用WordPress

    WordPress 去掉底部的自豪的采用WordPress  

  9. WordPress 去掉功能中的 wordpress.org

    WordPress 去掉功能中的 wordpress.org  

随机推荐

  1. Ubuntu上查内存情况

    free -h

  2. .Net Framework4.5.2 源码命名空间简析

    Miscosoft目前除.Net Core开源外,对于.Net4.5.1 , 4.5.2等后续版本同样开源.资源中包含sln,csproj等以方便我们在vs中打开它们,不过我们不能编译它,因为它缺少r ...

  3. 3、一、Introduction(入门):2、Device Compatibility(设备兼容性)

    2.Device Compatibility(设备兼容性)   Android is designed to run on many different types of devices, from ...

  4. Nginx-介绍nginx的两篇博客

    1. 一篇博客1.1)文章中间介绍配置文件的结构1.2)文章末尾可设置拒绝的ip,允许的ip博客地址:http://www.cnblogs.com/knowledgesea/p/5175711.htm ...

  5. 系统信号(signal)与其他(定时器,退出清理等)

    信号signal,可以用作进程线程通信,也可以用作接收中断后退出,退出时,清理资源,记录日志.python相关包为signa. linux信号表 root@server:~# kill -l ) SI ...

  6. arthas使用分享

    文章目录准备启动Demo进入arthas控制台基础命令jvm相关class/classloader相关monitor/watch/trace相关options管道后台异步任务Web Console其他 ...

  7. php面试题之一——HTML+CSS(基础部分)

    一.HTML + CSS部分 1. 请说明 HTML 文档中 DTD 的意义和作用(酷讯) DTD,文档类型定义,是一种保证 html 文档格式正确的有效方法,在解析网页时,浏览器将使用 DTD 来检 ...

  8. JavaのEclipse安装Tomcat插件

    由于我装的eclipse是SE版,所以没有Servlet项目,需要自己安装插件. 一:首先到Tomcat的官网下载对应Tomcat版本. http://tomcat.apache.org/ 现在tom ...

  9. mui---父页面跳子页面刷新子页面

    最近在做项目,遇到一个问题,从父页面跳转到子页面,不会刷新子页面的问题. 解决方法:可以在跳转的时候,使用openWindow来进行跳转,接下来配置跳转打开页面的参数: 具体如下: mui.openW ...

  10. day_5.26python面试重点

    列表生成式: ''' 2018-5-26 19:40:58 生成器(generator):在Python中,这种⼀边循环⼀边计算的机制. ''' # 第一种实现 :只要把⼀个列表⽣成式的[ ]改成( ...