0

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!

Afsanefda
  • 3,069
  • 6
  • 36
  • 76

1 Answers1

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.

GrahamTheDev
  • 22,724
  • 2
  • 32
  • 64
  • You mean something like => lighthouse http://somepage.com/ --view ? – Afsanefda Nov 02 '20 at 15:43
  • When using this nodejs lighthouse lib do you think something will be cached? – Afsanefda Nov 02 '20 at 15:44
  • Yes `lighthouse http://localhost/yoursite --output html --output-path ./report.html` would put the HTML report into a folder. – GrahamTheDev Nov 02 '20 at 15:45
  • By default nothing is cached, if you want to cache you can pass `--disable-storage-reset ` – GrahamTheDev Nov 02 '20 at 15:45
  • Thanks, and one more question. Every time the results are different is there a way to make an overall average? or I should do it manually? is this reliable? – Afsanefda Nov 02 '20 at 15:45
  • 1
    your results should not be vastly different between runs, if they are that is often a symptom of a server at capacity (or your local system being slow depending on where you are testing from) or it could be race conditions in your code that cause different layout shifts, Time To Interactive (TTI) etc. – GrahamTheDev Nov 02 '20 at 15:47
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/223992/discussion-between-afsanefda-and-graham-ritchie). – Afsanefda Nov 02 '20 at 15:47
  • https://github.com/GoogleChrome/lighthouse/blob/master/docs/variability.md is a useful document to see likely and unlikely causes of vastly different results. – GrahamTheDev Nov 02 '20 at 15:47