I am not even sure if something like I want is possible, so I am asking you guys to just let me know if anyone did that before. So, my goal is to when I click on "Publish" website in VS2010, to have all javascript files compressed into one, same with css and then in my layout file change the references from all different js and css files to only those two merged ones. Is that doable? Or maybe it's doable but in more manual way?
Of course the goal here is to have only two calls to external files on the website, but when I develop I need to see all files so that I can actually work with it. I guess I could do it manually before each push, but I'd rather have it done automatically using some script or something. I didn't try anything yet, and I am not looking for ready solution, I am just looking to get to know the problem better and maybe some tips.
Thanks a lot!
To minify CSS, try CSSNano and csso. To minify JavaScript, try UglifyJS. The Closure Compiler is also very effective. You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.
Javascript code can be compressed in one or more of the following ways: By removing white spaces and indentation. By shortening variable names to single characters. By removing new line characters.
The more complex and larger the CSS files are, the longer the visitor has to wait until the site has completely finished loading. By compressing the CSS, you can reduce the size of the CSS file and increase the performance of your website.
This is built into ASP.net 4.5. But in the mean time, you should look at the following projects
Scott Hanselman wrote a good overview blog post about this topic a while back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With