├── favicon.ico ├── .github └── workflows │ └── main.yml ├── README.md ├── LICENSE ├── style.css ├── index.html └── script.js /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skalman/UglifyJS-online/HEAD/favicon.ico -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Pages 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | deploy: 8 | 9 | if: github.actor == github.repository_owner 10 | runs-on: ubuntu-latest 11 | permissions: 12 | contents: write 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.ref }} 15 | 16 | steps: 17 | - uses: actions/checkout@main 18 | - name: update 19 | run: bash build/update.sh 20 | # Deploy the site 21 | - name: Deploy 22 | uses: peaceiris/actions-gh-pages@v4 23 | with: 24 | github_token: ${{ secrets.GITHUB_TOKEN }} 25 | publish_dir: public 26 | force_orphan: true 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UglifyJS: Online JavaScript minifier 2 | ==================================== 3 | 4 | UglifyJS 3 is an excellent tool to help you minify your JavaScript! It's a tried and tested tool, used by libraries such as jQuery. 5 | 6 | This is a simple wrapper for the browser around the minifier; the hard work is done by the Uglify team. If you need an automated solution, I suggest checking out the [source code](https://github.com/mishoo/UglifyJS2), intended for Node.JS. 7 | 8 | Do you want to help improve this tool? It's on [Github](https://github.com/Skalman/UglifyJS-online). 9 | 10 | 11 | License 12 | ------- 13 | 14 | The wrapper was created by [Dan Wolff](https://danwolff.se/). The wrapper is in the public domain. Attribution not required but appreciated. 15 | 16 | UglifyJS is released under the BSD license, copyright Mihai Bazon. For more information, check out the project's [Github page](https://github.com/mishoo/UglifyJS2/). 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: -moz-border-box; 3 | box-sizing: border-box; 4 | } 5 | 6 | .i { 7 | display: none; 8 | } 9 | 10 | .s-input .i-input, 11 | .s-options .i-options, 12 | .s-info .i-info, 13 | .s-output .i-output, 14 | .s-error .i-error { 15 | display: block; 16 | } 17 | 18 | html, body { 19 | height: 100%; 20 | margin: 0; 21 | min-height: 18em; 22 | padding: 0; 23 | font: 100%/1.5 Arial, sans-serif; 24 | background-color: #acc; 25 | } 26 | 27 | .header { 28 | min-height: 4em; 29 | width: 50%; 30 | } 31 | .header a { 32 | color: inherit; 33 | text-decoration: none; 34 | } 35 | 36 | .tools { 37 | margin-top: 0.5em; 38 | } 39 | button { 40 | line-height: 1.5; 41 | } 42 | .btn-main { 43 | font-weight: bold; 44 | } 45 | 46 | h1 { 47 | font: bold 2em/1 Arial, sans-serif; 48 | margin: 0; 49 | padding: 0.5em; 50 | } 51 | 52 | .content { 53 | position: relative; 54 | height: 26em; 55 | height: -moz-calc( 100% - 8em ); 56 | height: -webkit-calc( 100% - 8em ); 57 | height: calc( 100% - 8em ); 58 | margin-bottom: 0.25em; 59 | } 60 | 61 | .col { 62 | float: left; 63 | height: 100%; 64 | width: 50%; 65 | padding: 0 1em; 66 | } 67 | .col > *:first-child { 68 | margin-top: 0; 69 | } 70 | 71 | .i-output p { 72 | position: absolute; 73 | top: -2em; 74 | margin: 0; 75 | } 76 | 77 | #in, #options, #out { 78 | height: 99%; 79 | width: 100%; 80 | } 81 | 82 | .pull-right { 83 | float: right; 84 | } 85 | 86 | pre { 87 | word-wrap: break-word; 88 | overflow-wrap: break-word; 89 | } 90 | 91 | #error { 92 | background: #fff0f0; 93 | border-left: 0.5em solid #c00; 94 | padding: 0.5em 0.5em 0.5em 1em; 95 | } 96 | 97 | mark { 98 | background: #fc0; 99 | color: #000; 100 | padding: 0.3em; 101 | border-radius: 0.3em; 102 | font-weight: bold; 103 | } 104 | 105 | small { 106 | opacity: 0.7; 107 | } 108 | 109 | code { 110 | border-radius: 0.3em; 111 | background: rgba(255, 255, 255, 0.2); 112 | padding: 0.2em; 113 | border: 1px solid rgba(0, 0, 0, 0.2); 114 | } 115 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UglifyJS 3: Online JavaScript minifier 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

UglifyJS 3: Online JavaScript minifier

22 |
23 | 24 | 25 |
26 |
27 | 31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 | 139 |
140 | 141 | 142 |
143 |
144 | 145 |
146 |

147 | UglifyJS 3 is an excellent tool to help you minify your JavaScript! 148 | It's a tried and tested tool, used by libraries such as jQuery.

149 | 150 |

151 | This is a simple wrapper for the browser around the minifier; 152 | the hard work is done by the Uglify team. 153 | If you need an automated solution, I suggest checking out the 154 | source code, intended for Node.JS.

155 | 156 |

157 | Do you want to help improve this tool? It's on Github.

158 | 159 |

160 | This wrapper for the browser was created by Dan Wolff. 161 | 162 | Version uglify-es 3.3.9.

163 | 164 |
165 | 166 |
167 |

168 | The minified output ()

169 | 170 |
171 | 172 |
173 |

174 | 	
175 |
176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | /*global minify:false, JS_Parse_Error:false */ 2 | /*jshint globalstrict:true */ 3 | 4 | 'use strict'; 5 | 6 | var default_options = {}; 7 | 8 | function $(id) { 9 | return document.getElementById(id); 10 | } 11 | 12 | 13 | // Handle the UI 14 | 15 | var uglify_options; 16 | var $options = $('options'); 17 | var $out = $('out'); 18 | var $in = $('in'); 19 | var $error = $('error'); 20 | var $stats = $('stats'); 21 | var $body = document.body; 22 | var $btn_options = $('btn-options'); 23 | var $btn_options_save = $('btn-options-save'); 24 | var $cb_as_i_type = $('cb-as-i-type'); 25 | 26 | 27 | $('header-link').onclick = go_to_start; 28 | $('btn-go').onclick = go; 29 | $btn_options.onclick = show_options; 30 | $btn_options_save.onclick = set_options; 31 | $('btn-options-reset').onclick = reset_options; 32 | $in.oninput = $in.onkeyup = $in.onblur = $in.onfocus = go_ait; 33 | $cb_as_i_type.onclick = set_options_ait; 34 | $out.onfocus = select_text; 35 | 36 | var default_options_text; 37 | set_options_initial(); 38 | 39 | 40 | function hide(class_name) { 41 | var names = class_name.split(' '); 42 | var cur = ' ' + $body.className + ' '; 43 | for (var i = 0; i < names.length; i++) { 44 | while (cur.indexOf(' ' + names[i] + ' ') >= 0) { 45 | cur = cur.replace(' ' + names[i] + ' ', ' '); 46 | } 47 | } 48 | 49 | $body.className = cur.replace(/^\s+|\s+$/g, ''); 50 | } 51 | 52 | function show(class_name) { 53 | $body.className += ' ' + class_name; 54 | } 55 | 56 | function show_options() { 57 | show('s-options'); 58 | hide('s-input'); 59 | } 60 | 61 | function get_options(value) { 62 | /*jshint evil:true */ 63 | return new Function('return (' + (value || $options.value) + ');')(); 64 | } 65 | 66 | function set_options() { 67 | var old_options = uglify_options; 68 | try { 69 | uglify_options = get_options(); 70 | 71 | // The options could be parsed. Try to update localStorage. 72 | try { 73 | if (default_options_text === $options.value) 74 | localStorage.removeItem('uglify-options'); 75 | else 76 | localStorage.setItem('uglify-options', $options.value); 77 | } catch (e) {} 78 | 79 | // Run Uglify with the new options. 80 | go(true); 81 | 82 | show('s-input'); 83 | hide('s-options'); 84 | return true; 85 | } catch (e) { 86 | if (e instanceof JS_Parse_Error) { 87 | // the options are actually okay, just the code that's bad 88 | show_error(e, $in.value); 89 | return true; 90 | } else { 91 | uglify_options = old_options; 92 | show_error(e); 93 | return false; 94 | } 95 | } 96 | } 97 | 98 | function reset_options() { 99 | $options.value = default_options_text; 100 | set_options(); 101 | } 102 | 103 | function set_options_ait() { 104 | try { 105 | if ($cb_as_i_type.checked) 106 | localStorage.removeItem('uglify-options-disable-ait'); 107 | else 108 | localStorage.setItem('uglify-options-disable-ait', 1); 109 | } catch (e) {} 110 | } 111 | 112 | function set_options_initial() { 113 | default_options_text = $options.textContent || $options.innerText; 114 | default_options = get_options(default_options_text); 115 | 116 | // If there are options saved with localStorage, load them now. 117 | try { 118 | var options_text = localStorage.getItem('uglify-options'); 119 | if (options_text) { 120 | $options.value = options_text; 121 | } 122 | $cb_as_i_type.checked = !localStorage.getItem('uglify-options-disable-ait'); 123 | } catch (e) {} 124 | 125 | try { 126 | uglify_options = get_options(); 127 | } catch (e) { 128 | // if it didn't work, reset the textarea 129 | $options.value = default_options_text; 130 | uglify_options = default_options; 131 | } 132 | } 133 | 134 | function encodeHTML(str) { 135 | return (str + '') 136 | .replace(/&/g, '&') 137 | .replace(/\n' + 205 | 'Line ' + e.line + ', column ' + (e.col + 1) + '\n\n' + 206 | (lines[e.line-2] ? (e.line - 1) + ': ' + encodeHTML(lines[e.line-2]) + '\n' : '') + 207 | e.line + ': ' + 208 | encodeHTML(line.substr(0, e.col)) + 209 | '' + encodeHTML(line.substr(e.col, 1) || ' ') + '' + 210 | encodeHTML(line.substr(e.col + 1)) + '\n' + 211 | (lines[e.line] ? (e.line + 1) + ': ' + encodeHTML(lines[e.line]) : ''); 212 | } else if (e instanceof Error) { 213 | e = e.name + ': ' + encodeHTML(e.message) + ''; 214 | } else { 215 | e = '' + encodeHTML(e) + ''; 216 | } 217 | 218 | $error.innerHTML = e; 219 | } 220 | 221 | function go_to_start() { 222 | clearTimeout(ait_timeout); 223 | hide('s-options s-error s-output'); 224 | show('s-input s-info'); 225 | return false; 226 | } 227 | 228 | function select_text() { 229 | /*jshint validthis:true */ 230 | var self = this; 231 | self.select(); 232 | 233 | self.onmouseup = self.onkeyup = function() { 234 | // Prevent further mouseup intervention 235 | self.onmouseup = self.onkeyup = null; 236 | self.scrollTop = 0; 237 | return false; 238 | }; 239 | return false; 240 | } 241 | --------------------------------------------------------------------------------