如何在本地主机上使用谷歌的页面速度洞察工具 [英] How to use google's page speed insight tool on localhost

查看:100
本文介绍了如何在本地主机上使用谷歌的页面速度洞察工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 google 的页面速度洞察工具,在生产中,它工作正常.

I'm using google's page speed insight tool and on production, it works fine.

但是可以在 localhost 上使用它吗?或者是否有任何等效的工具来测试本地页面?

But is it possible to use it on localhost? or are there any equivalent tool for testing local pages?

我知道灯塔标签也是一种选择,但指标有些不同!我需要在该服务中使用的相同 API!

I know the lighthouse tab is also an option but the metrics are somehow different! I need the same API used in that service!

推荐答案

您可以使用 Lighthouse 命令线路接口 (CLI)(或 从 NodeJS 运行它 如果您对此很熟悉),这是为 Page Speed Insights 提供动力的引擎.

You can use Lighthouse Command Line Interface (CLI) (or run it from NodeJS if you are familiar with that), this is the engine that powers Page Speed Insights.

这样您就可以配置 CPU 速度减慢和网络延迟与您体验 Page Speed Insights 的方式密切匹配.

That way you configure CPU slowdown and network latency to closely match how you experience Page Speed Insights.

对于浏览器中的 Lighthouse,指标应该是相同的(就测量什么而言).

With regards to Lighthouse in the browser, the metrics should be the same (in terms of what is measured).

如果您得到的性能数据差别很大,可能有多种原因,例如:

If you are getting vastly different performance numbers there may be several causes such as:

  • 插件(所以在隐身模式下运行)
  • 延迟差异(例如,如果您的网站位于印度或澳大利亚,则使用 Google 在美国的服务器时延迟会很高,因此您将从本地主机获得更好的分数)
  • 设置(不运行模拟"节流).

您可以在我给出的这个答案中找到有关 Lighthouse CLI 优势的更多信息.

You can find a bit more info on the Lighthouse CLI advantages in this answer I gave.

这篇关于如何在本地主机上使用谷歌的页面速度洞察工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆