ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
https://zelark.github.io/nano-id-cc/
MIT License
24.62k stars 790 forks source link

feat: Re-optimize the alphabet for gzip after size-limit update #309

Closed subzey closed 3 years ago

subzey commented 3 years ago

Now that after the size-limit update the exports are tree-shaked and the alphabet should be re-optimized for gzip. For urlAlphabet The only string for the backreferences we can rely on is "use strict", so the new alphabet is

'use ... rict'

Notice the the string quotes are the part of the backreferences, too. I really hope the minifier would use the same quotes both for "use strict" and the alphabet string.

For non-secure nanoid, the opttimization is just better-than nothing. So I guess compression enthusiasts can improve it further.

  urlAlphabet
  Package size is 5 B less than limit
  Size limit: 66 B
  Size:       61 B with all dependencies, minified and gzipped

  non-secure nanoid
  Package size is 6 B less than limit
  Size limit: 124 B
  Size:       118 B with all dependencies, minified and gzipped
ai commented 3 years ago

😍😍😍