Given that uglification involves some minification in the process, does it still make sense to do both minify and uglify? If yes, should one minify or uglify first? Is it enough to do uglify only? Will the code be more obfuscated if both are done?
There is no real distinction between the two. Even Uglify calls itself a minification toolkit.
The distinction could be more relevant when comparing JS minification to CSS minification - CSS minification involves only removing whitespace - the original code remains intact.
With JS it is possible to not only remove whitespace, but also to make transformations to the code, such as truncating variable names to single characters.
Minifying JavaScript not only makes the source smaller, it also makes the code less readable, or obfuscates it. But do not operate under the assumption that minification or uglification, or whatever you want to call it, is a security measure. It isn't encryption. The code is harder to read, but not impossible to read, and while it's not usually possible to return minified code back to its original form, it is possible to 'beautify' it and make it more readable.
It doesn't make sense to both minify and uglify because most minifiers will both remove whitespace and unnecessary characters, as well as obfuscate the code. All you're doing is introducing another build step.
Minifying is just removing unnecessary white-space and redundant like comments and semicolons. And it can be reversed back when needed.
Uglifying is transforming the code into an "unreadable" form by changing variable names, function names, etc, to hide the original content. Once it is used there's no way to reverse it back.
Some libraries like UglifyJS does minification when used, by removing unnecessary parts. But in general Uglifying is making the code unreadable.
Minifying your code speeds up your page loading, making visitors and search engines happy and it is also readable. Most major browsers minify the code before execution.
Uglifying and minifying JS code makes loading pages a little faster and makes code less readable but not unreadable. Like someone just said, we should not confuse uglifying and minifying for encryption.
© 2022 - 2024 — McMap. All rights reserved.