Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Minify a function...
- FUNCTION.toString()
- .replace(/\/\/.*?\n/g, "") // "//" comments
- .replace(/\/\*.*?\*\//, "") // "/**/" comments
- .replace(/\s+/g, " ") // Replace multiple spaces with one space
- .replace(/([^\w])\s/g, "$1") // Remove spaces after non-alphanumeric characters (;.,[]{}()<>=-+ etc.)
- .replace(/\s([^\w])/g, "$1") // Remove spaces before non-alphanum chars
- .replace(/console\.log\(.*?\)([;}])/g, "$1") // Remove console.log()
- .replace(/;+/g, ";") // Remove multiple semicolons
- .replace(/{;/g, "{") // Remove semicolons after a {
- .replace(/;}/g, "}"); // remove semicolons before a }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement