C# tip, Clean Code, MVC, Non-functional Requirements, Performance

Performance in ASP.net and C# – Bundling and Minification – Part #2

This is a very quick follow up to my earlier post on bundling and minification – an issue we found and the solution.

While examining the content of the (supposedly) bundled and minified resources, I noticed one of my CSS files wasn’t minified. It had the error message at the top of the file:

/* Minification failed. Returning unminified contents.

(2628,2): run-time error CSS1031: Expected selector, found '@charset'

After some investigation, we found that our CSS files (originally generated using SASS) had a header at the top of each file saying “@charset = ‘utf-8′”.

Removing lines like this allowed the contents to be minified. Deleting the line was fine, as we had the charset defined in our layout page meta data, and therefore this was already in the HTTP Headers for the page.

Hopefully this helps someone out there who’s having the same issue.