Minify Dark/Light Mode Switching JavaScript

I did not question you to offend you.

However, in your last post, you stated you had a landing page that loaded in 500 ms (which is a half second. Incredible!) Then you stated that you made two copies. One without JS that loaded in 1 second (100 ms) and one with JS that loaded in 2 seconds (200 ms). These numbers seem impossible. The copied site without the JS should have loaded in the same 500 ms as the original, but you’re saying it got 80% faster? I would love to know where you are getting these number from, because they sound made up. Care to post a link to your landing page?

I did some testing today. I exported two copies of the BSS Startup Modern template, one with the light/dark JS in the HTML and one without it. I then ran 10 tests on each website over a period of about a half hour. Lighthouse can have slight variations from test-to-test due to many factors, but averaging the numbers over the 20 tests, both sites

  • scored 98-99 on Performance
  • scored 10-20 ms blocking time
  • scored 2.1 - 2.2 time to interactive

Both had identical speed indexes (2.0 s)

Sometimes the site WITH the script had a slightly lower blocking time than the site without the script. Again, Lighthouse tests are not perfect.

I further drilled down and looked at the actual time the browser took to parse the HTML of both sites. Again, they were (for all intents and purposes) identical. 10-12 ms. And again, sometimes the site with the script loaded faster, other times the site without the script loaded faster. And we’re talking about 1-2 ms.

So it appears what Martin said in the first place is correct. The script will not affect your Lighthouse scores.

(And FWIW, for the vast majority of humans, anything less than 100-200 ms (.1 to .2 seconds) is perceived as “instantaneous.”)

I said I made two copies. That implies there are three landing pages total: the original + two copies. Also, 1000 ms is 1 second.

And you could run however many tests that you want. My sales data show that even a 0.5 second delay causes a non-trivial reduction in revenue.

My mistake. So your copied site went from 500 ms to 1000 ms without any changes, and with added JS it went to 2000 ms?

I agree that a .5 second delay would affect conversions.

Either way, the light/dark JS script does not cause any measurable delay. So minifying it won’t do anything to affect the website speed.