admin avatar

在网页中使用dns-prefetch声明提高网页加载响应速度

🕦 by admin

使用 https://gtmetrix.com/?src=vpslala.com

测试网页评分时,发现唯一暂时能够调优的

就是使用dns-prefetch声明提高网页加载响应速度了

其实最早发现使用dns-prefetch那时候是折腾Wordpress时

那时候不懂就把不是Wordpress程序的网站也把Wordpress默认的dns-prefetch

写入到网页头部文件中,其实这是错误的。

https://gtmetrix.com/preconnect-to-required-origins.html?src=vpslala.com

在这篇文章已经介绍的很详细了

也就说你自己的网页需要加载第三方资源的时候,使用dns-prefetch就是科学的。

比如vpslala网页使用了很多第三方网站资源,所以dns-prefetch这样写

1
2
3
4
5
6
7
8
9
<link rel='dns-prefetch' href='//cc.adingo.jp' />
<link rel='dns-prefetch' href='//rubiconproject.com' />
<link rel='dns-prefetch' href='//sharethis.com' /> 
<link rel='dns-prefetch' href='//google-analytics.com' />
<link rel='dns-prefetch' href='//cloudflareinsights.com' />
<link rel='dns-prefetch' href='//googletagmanager.com' />
<link rel='dns-prefetch' href='//googlesyndication.com' />
<link rel='dns-prefetch' href='//doubleclick.net' />
<link rel='dns-prefetch' href='//jsdelivr.net' />

经过测试发现,网页加载大概提升了快1秒左右。。。

💘 相关文章

写一条评论