This is of course assuming you don’t have to maintain support for extremely old browsers that actually require semicolons in JavaScript, which you probably don’t. Basically, a semicolon and a newline character (edit: I should clarify that I mean the Unix-style LF as opposed to Windows’s CRLF, every reasonably modern web browser should understand the former even if it’s on Windows) take up the same amount of bytes in both ASCII and UTF-8, so does it really matter if each statement in a minified file is separated by a new line or a semicolon? There is also a benefit to using new lines where it’s at least somewhat human readable (albeit without indents) instead of almost completely unreadable if everything was on one line. So why aren’t there any minifiers that produce new line separated files?


When producing a single line file, the minifier doesn’t need to insert a semicolon after every statement. A decent minifier will only insert semicolons where absolutely necessary, omitting them in places where the parser would automatically insert them anyway. See this blog post that talks about automatic semicolon insertion.

Take for example the client.js file on this site ( Minified to a single line and with the ~5400 semicolons left in, it weighs roughly 1.37Mb.

If we prettify it (it comes to ~56000 lines for me), remove all indentation and delete all semicolons, the weight increases to 1.53Mb with LF and 1.58Mb with CRLF.

The JavaScript community in Lemmy

    A community about JavaScript, the ECMAScript standard, and programs that make use of JS such as Node.js.

    • 0 users online
    • 1 user / day
    • 1 user / week
    • 1 user / month
    • 3 users / 6 months
    • 287 subscribers
    • 37 Posts
    • Modlog