问题
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