2

I saw this but the answers focus on the human challenges of maintaining JS without semicolons, not the machine performance.

I'm not interested in that. Let's assume that I'm using a language that compiles to JS and will generate huge scripts, so the effects of ASI or not-ASI will appear in the aggregate.

Does a browser process the javascript faster when the JS relies on automatic semicolon insertion, or without?

And if it depends, what is the filesize, or ratio of semicolons-to-characters perhaps, at which one strategy wins over the other?

3
  • 2
    Test it. I suspect that you'll find differences in different JavaScript implementations.
    – Brad
    Oct 24, 2014 at 2:44
  • I would hazard a guess that explicit semicolons are going to be quicker to compile, by an absolutely insignificant amount. It should be many orders of magnitude smaller than the time it takes to load the script off disk. Oct 24, 2014 at 2:47
  • @jfriend00 The answers in the (linked) question are trying to solve the XY problem, and summarily punt on actually answering the question. Hence this question remains unanswered. Oct 24, 2014 at 13:10

1 Answer 1

3

Here is a link that breaks down the performance of ASI vs non-ASI (http://jsperf.com/asi-performance/2).

As you will see in most cases there is a minuscule loss in performance when relying on ASI.

Hope this helps.

2
  • 1
    Odd, I ran the tests three times and consistently saw a minuscule improvement when relying on ASI. I was surprised. Mar 27, 2017 at 14:52
  • I did too. Sometimes using ASI came out ahead, sometimes without ASI. It seemed random and probably didn't have much to do with ASI at all.
    – xeruf
    Sep 2, 2017 at 0:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.