Most JavaScript engines decorate functions. Knowing this, here is a function that can help you solve your problem:
function beautify (code) { return new Function(code).toString(0) .replace(/^function\s*\w*\s*\(\s*\)\s*{?|;?}?$/g, "") .replace(/\n\s{4}/g, "\n").replace(/^\n/, "") }
SpiderMonkey and Rhino may also not decorate (reduce) them if you use function.toString(-1) , if you ever need to do the opposite. I also have a function for this:
function minify (code) { new Function(code).toString(-1) .replace(/^function\s*\w*\s*\(\s*\)\s*{?|;?}?$/g, ""); }
Edit: It seems you only need to do this for tinymce.js. You can download TinyMCE source code as an open source.
source share