How to use google's page speed insight tool on localhost

与世无争的帅哥 提交于 2021-01-29 07:11:05

问题


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

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

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


回答1:


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.

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

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:

  • plugins (so run in incognito mode)
  • latency difference (if your website is in India or Australia for example then the latency will be high using Google's servers in America so you will get better scores from localhost)
  • settings (not running "simulated" throttling).

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



来源:https://stackoverflow.com/questions/64647628/how-to-use-googles-page-speed-insight-tool-on-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!