简体   繁体   中英

requirejs optimizer vs asp.net style/script bundling vs gzip compression

Using asp.net server side I can do style bundling for .css files and script bundling for .js files. Alle .css or .js files are packed into one file for each format and minified.

Now I am also using requirejs on client side and asked myself now should I still use the requirejs optimizer to compress the .css and .js files like my javascript libraries (Often these libraries are already compressed...). Ok there are still the requirejs modules which are my viewmodels etc... which can be compressed but often those files are 3-4 kb not really worth the effort I think.

I also asked myself is requirejs optimizer worth the time I have to invest when there is anyway gzip compression for files which gives normally the best results.

So do you think I should go for requirejs optimizer or is style/script bundling on asp.net and gzip compression on IIS server totally enough?

Optimization with RequireJS is similar to what asp.net bundling does. Bundling achieves a slightly different goal to gzipping.

The point of bundling, is to lower the amount of http requests you need to make. Making 1 request is better than 5.

That file requested can then be minified & gzipped to reduce the size of data transferred.

Similar reductions can be achieved by using well-known cdn's. The idea being, why download jquery from your server, again, when the user probably has jQuery from XYZ's cdn already in their cache?

Whether you choose to use ASP.Net's bundling or RequireJS, is really up to you. I prefer ASP.Net bundling as it requires no additional steps in my build & deploy processes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM