118 points · by eashish93 · 8y ago · 36 comments
I haven't done this exact thing, but I've done similar things many times. Not every project has or should have a build process. And unfortunately not all of them even have a command line...
Either setup a trivial build script, or don't do it at all.
EDIT: Clearly HN disagrees with me. Tell me, what does being a cowboy get you here?
If it's a measurable performance boost, then as soon as you patch it again your site will seem slower. Unless you then manually minifiy again. And again. Until you setup a build script.
If it's not a measurable performance boost, (And I doubt that you know either way because if you're not setting up a trivial build script then I highly doubt you're putting in the time to profile) then what do you get? The next person to come along gets to have a harder time debugging because you don't have source maps?
It's my go-to Numberwang encoder!
This list may not be representative of “all free online tools” but is sufficient for the context. Perhaps the common thread amongst all of them is that they are served over the interweb. And I wonder what’s the use case?
Edit: typo
Take this input HTML:
<!doctype html>
<html lang="en-au">
<head>
<meta charset="utf-8">
<title>This is a title</title>
</head>
<body class="foo">
<h1>Well.</h1>
<p>I wonder…</p>
</body>
</html>
It produces this output: <!DOCTYPE html><html lang="en-au"><head><meta charset="utf-8"><title>This is a title</title></head><body class="foo"><h1>Well.</h1><p>I wonder…</p></body></html>
It converted “doctype” to uppercase (equivalent, but bad for compression). It didn’t strip <head> and </head> as superfluous. It didn’t remove unnecessary quotes around attribute values. It didn’t remove the unnecessary </p></body></html> closing tags.Here’s what I say it should have emitted:
<!doctype html><html lang=en-au><meta charset=utf-8><title>This is a title</title><body class=foo><h1>Well.</h1><p>I wonder…
30 characters shorter, and structurally equivalent.Just because you can write your whole app in one line of JavaScript doesn't mean you should maintain that as source code. You sure want that as your production bundle though.
also seems like a terribly brittle externality to add to my life
Check out https://jsonchecker.com/
It validates and formats JSON.
Let me know if you have any feedback!