Siorki / RegPack

Self-contained packer for size-constrained JS code
Other
299 stars 14 forks source link

[Online demo] Sync the input textarea with the URL's hash #33

Closed xem closed 8 years ago

xem commented 8 years ago

Hello!

Closure compiler has this handy feature:

http://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250Afunction%2520hello%28name%29%2520%257B%250A%2520%2520alert%28%27Hello%252C%2520%27%2520%252B%2520name%29%253B%250A%257D%250Ahello%28%27regpack%27%29%253B%250A%250A

when you minify some code, it is copied in the URL's hash

And on load, if a hash is set, the input is pre-filled with its content

Could we add this to RegPack's online demo?

Siorki commented 8 years ago

Done. The input code is read from the URL upon loading the page, and appended upon clicking "Pack", both with base-64 encoding. Using # as separator (as opposed to ?) prevents the browser from immediately reloading the page.