UglifyJS-online icon indicating copy to clipboard operation
UglifyJS-online copied to clipboard

Browser hangs on large files

Open tom-sherman opened this issue 6 years ago • 2 comments

Should probably utilise a Web Worker to perform the minification in a separate thread.

tom-sherman avatar Sep 04 '19 14:09 tom-sherman

I've done some experimenting on my own minifier-in-a-browser (https://github.com/tom-sherman/yet-another-js-online-minifier)

Turns out that only some of the freeze up is caused by the minification, the rest is caused by just pasting large amounts of text into an input.

In my version, I solved the freezing issue completely by doing two things:

  1. Offload the minification to a worker. I used terser for minification but should work just as well with uglify.
  2. Use CodeMirror for the input

CodeMirror sidesteps the paste-jank by virtualising all of the code lines and only rendering to the DOM those that are on screen.

tom-sherman avatar Sep 05 '19 22:09 tom-sherman

Sorry for the late reply. This seems like a great idea. If you'd like to submit a pull request, I'd be happy to merge it.

Skalman avatar Sep 27 '19 19:09 Skalman