I was discussing with a colleague about JavaScript while looking at some snippets. We noticed that these snippets were missing the ; at the end of the statements. We all know that JS is interpreted correctly even if no semicolon is shown at the end of a line, but I was wondering if this affects somehow the performance of evaluation, since it is an interpreted language.
I was discussing with a colleague about JavaScript while looking at some snippets. We
Share
A javascript file with spaces, semi-colons and comments is heavier. That’s the main impact.
But you’re a coder and you have to maintain the code, so this very slight impact is much less important than the adverse one on readability. And omitting the semicolons means you know when you can omit them. But the rules aren’t so simple and learning them isn’t worth your time.
Leave the semi-colons where they are, you’ll avoid bugs.
And use a minifier to build a more concise code for the browser if you want to have the lightest possible code. It’s its duty, not yours.