Menu

Tech tip - Using 'JSMin' to remove commented-out code from JavaScript

I use Douglas Crockford's 'JSMin' minifier a lot.

I modified it to keep newlines so I can look through the results. You can find it at:
'https://github.com/Bert-Beckwith/myjsmin'

'jsmin.c' is a small C program that removes JavaScript comments and excess whitespace.

I often comment out old code rather than remove the code, so I use 'JSMin' to look at what is left. Afterwards I say ':g/^$/d' in 'vim' to remove blank lines. I really should just remove the old code and learn to use my source control system better.

I also use 'JSMin' to minify my game, partly so that the input to 'UglifyJS' is smaller. I use an online version of 'UglifyJS' as my Linux system at home is a bit too old to run it. 'JSMin' is small and fast - I can run it in the background whilst playing my game.

There are more tips at: bbingo.xyz/t

Posted by Bert Beckwith 2025-03-20 Labels: javascript

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.