andrewdavey / cassette

Manages .NET web application assets (scripts, css and templates)
http://getcassette.net
MIT License
534 stars 143 forks source link

Ignore minified file when non-minified file also exist. #130

Closed andrewdavey closed 12 years ago

andrewdavey commented 12 years ago

Classic case is when some nuget package has both .min.js an .js files. Cassette should ignore the .min.js files.

Also must handle the .debug.js and .js option. In this case .js is the minified version to ignore.

Also handle .min.css and .css

honestegg commented 12 years ago

Do you think it would be worthwhile to have Cassette use the minified version if it is available? (instead of doing the minification itself)

I guess I would prefer to have this as an option -- especially for libraries like jQuery. That way Cassette doesn't have to try to minify these and the minified version comes via the official channel.

andrewdavey commented 12 years ago

When debugging JavaScript, I often find myself stepping into jQuery, knockout, etc. I certainly prefer these files to not be minified when that happens. Also, these libraries are usually combined with other shared scripts, so Cassette is going to have to run the minification process over the combined result anyway.

If you want to have a go at adding an option for switching which files are used, take a look at the v1.1 branch. You want to alter FileSearch and ConventionalMinifiedFileFilter

honestegg commented 12 years ago

I agree with you about being able to step into the non-minified versions of javascript libraries when debugging.

My thought is that if I have both jquery.js and jquery.min.js in my scripts folder I would like jquery.js to be used during development and jquery.min.js to be used in production and not have Cassette try to minify jquery.js when we already have a minified version available.

Thanks for the great tool. I'll take a look at the code and see if I can come up with something that makes sense.

kamranayub commented 12 years ago

@honestegg I think what @andrewdavey was saying is that if you have Backbone.min.js, it also depends on having underscore.min.js with it; I think he is saying that the minification runs AFTER concatenation, so it would end up minifying both pre-minified files.

I can't speak to how much work it'd be to change that (i.e. minify then concatenate) or whether that'd introduce more problems than it solves. I agree with you ideally Cassette shouldn't minify stuff that's already minified, I just don't know what that means in terms of the codebase.

honestegg commented 12 years ago

@kamranayub - Thanks. Yeah, once I downloaded the source I realized that is what it was doing.

On Wed, Feb 8, 2012 at 10:11 AM, Kamran Ayub < reply@reply.github.com

wrote:

@honestegg I think what @andrewdavey was saying is that if you have Backbone.min.js, it also depends on having underscore.min.js with it; I think he is saying that the minification runs AFTER concatenation, so it would end up minifying both pre-minified files.

I can't speak to how much work it'd be to change that (i.e. minify then concatenate) or whether that'd introduce more problems than it solves. I agree with you ideally Cassette shouldn't minify stuff that's already minified, I just don't know what that means in terms of the codebase.


Reply to this email directly or view it on GitHub: https://github.com/andrewdavey/cassette/issues/130#issuecomment-3870090

andrewdavey commented 12 years ago

Minification should happen after concatenation. This gives the minifier more understanding of the variables used, providing more options to minify.

I'm closing this particular issue as fixed. If you want to investigate changing Cassette to use .min.js and altering the pipeline to conditional minify and then combine, please create a separate issue and branch. It would be interesting to compare the two approaches for speed and file sizes.