Do not run this against minified JavaScript packages. The minified packages often rely on line returns to execute correctly.
This regular expression was designed to minify simple JavaScript.
(?s)[\t\r\n]|[ ][ ]+|/\*.*?\*/*
I put spaces in square brackets as a reminder that they exist. Spaces can be important. For example, $( "#foo #bar" )
should not become $("#foo#bar")
. However, we do want to remove spaces if they are used for indentation.