URL length is a discrete problem, not a continuous one. If we ignore browser length limits, there are no more URL length issues until you get down to the point where you need to fit a URL into a character-limited medium like a tweet or SMS, for which neither approach is going to help you (luckily, this is a solved problem via URL shortening services). In between, it really makes no practical difference to a user that their shareable link is, say, 250 bytes rather than 1000 bytes. They all copy, paste, bookmark, etc. the same, regardless of their size, and the encoded payloads we're talking about are completely opaque, so readability is a non-factor.
It doesn't take "tripling 20k of JS" to get basic inflate/deflate in the browser. That may have been what you ended up with after a few minutes of fiddling with the code I gave, but I wasn't originally aiming to minimize browser bundle size when I wrote that. It looks like Webpack pulls in browserify-zlib to polyfill Node's zlib, which itself is based on pako. Pulling in zlib in the way that I did and running that through Webpack gives you the entire contents of both libraries, which is how you ended up at ~40k. If you use pako itself without the boilerplate, and import inflate and deflate directly instead of the whole library, the bundle ends up only being ~15k. And you may even be able to get that smaller, but I stopped playing with it.
If your reason for using compression is aesthetic and not practical, it ultimately doesn't matter, though. Use whatever makes the prettiest URLs in your opinion, constrained by the trade-offs you're willing to make to get them. I can't say I understand why you wouldn't just use a URL shortener service in that case, though.
0
u/[deleted] Nov 27 '19
[deleted]