wordpress打开速度慢最佳解决方案

简介1:去掉google字体加载,这里推荐用插件:DisableGoogleFonts2:去掉head头部s.w.orgurl链接,在主题的function.php加入以下代码add_filter(‘wp_resource_hints’,’remove_dns_prefetch’,10,2);或functionremove_dns_prefetch($hints,$relation_type){if(

  

1:去掉google字体加载,这里推荐用插件:Disable Google Fonts

2:去掉head头部 s.w.org url链接,在主题的function.php 加入以下代码

add_filter('wp_resource_hints','remove_dns_prefetch',10,2);

functionremove_dns_prefetch($hints,$relation_type){if('dns-prefetch'===$relation_type){returnarray_diff(wp_dependencies_unique_hosts(),$hints);}return$hints;}

3:去掉加载表情包,代码如下:

remove_action('wp_head','print_emoji_detection_ ',7);remove_action('wp_print_styles','print_emoji_styles');add_filter('emoji_svg_url','__return_false');

4:去掉http头请求信息:(禁用rest api方法)如下:

:<http://localhost/wordpress/wp-json/>; rel="https://api.w.org/"

方法一:本站推荐用一个插件:Disable REST API

方法 二:主题function.php加入以下代码:

add_filter('rest_enabled','__return_false');add_filter('rest_jsonp_enabled','__return_false');remove_action('wp_head','rest_output_ _wp_head',10);remove_action('wp_head','wp_o _add_discovery_ s',10);

5:去掉其它无用的信息,都是加入主题function.php文件里的。代码如下:

remove_action('wp_head','feed_ s_extra',3);//去除评论feedremove_action('wp_head','feed_ s',2);//去除文章feedremove_action('wp_head','rsd_ ');//针对Blog的远程离线编辑器接口remove_action('wp_head','wlwmanifest_ ');//WindowsLiveWriter接口remove_action('wp_head','index_rel_ ');//移除当前页面的索引remove_action('wp_head','parent_post_rel_ ',10,0);//移除后面文章的urlremove_action('wp_head','start_post_rel_ ',10,0);//移除最开始文章的urlremove_action('wp_head','wp_short _wp_head',10,0);//自动生成的短链接remove_action('wp_head','adjacent_posts_rel_ ',10,0);///移除相邻文章的urlremove_action('wp_head','wp_generator');//移除版本号

6:wordpress 数据库连接地址问题

我们都知道,我们wordpress程序在安装的时候,都需要写数据库地址,默认的是localhost;

有一些服务商,填写localhost会造成数据库连接不上。这样就必须填写127.0.0.1;如果还连接不上再填写你的服务器真实IP;(因为有一些服务商连接数据库填写真实的ip地址,会造成网站等待时间过长!)

下载链接:网站源码/小程序源码/网站模板下载

版权声明

   站内部分内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供网络资源分享服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请 联系我们 一经核实,立即删除。并对发布账号进行永久封禁处理。在为用户提供最好的产品同时,保证优秀的服务质量。


本站仅提供信息存储空间,不拥有所有权,不承担相关法律责任。

给TA打赏
共{{data.count}}人
人已打赏
网站技巧

广告联盟被屏蔽后显示图片链接广告方法代码

2024-9-19 19:44:45

网站技巧

纯CSS使图片有放大效果代码

2024-9-19 19:44:48

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索