Minimizing Javascript [closed]
Ok, so I just learned about minimizing JS to make it load quicker, so what I've been doing is copying that and putting it into the JSbeautifier. However, when I do this it comes back as like 7k lines of JS and I'm curious if this is just one function or a whole library or does it开发者_开发知识库 depend?
The whole idea of minifying the javascript is to remove any and all unnecessary line breaks and white space and in the case of a good minifyers, it will rename variables as well.
The beautifyer ADDS line breaks and white space so as to make things more readable, which means you're circumventing the whole point of minification by putting your code into the beautifier. Run the beautifier on your non-minified code to make it more readable for you and when you're ready to publish it to the web, then minify it. Minified javascript is not meant to be readable.
I usually keep a development version and a release version. I test locally and then when I upload my changes, I minify.
Hope this helps.
To minify and/or pack, you can use jscompress.com
精彩评论