I am working on a website (.NET framework 4.8) with jquery front end. I made a BundleConfig (System.Web.Optimization), where I included all js files in bundles and set BundleTable.EnableOptimizations = true;
, but only some of the bundles are minified. As the official documentation only says enable that boolean, I am asking you what could be the reason for it minifying only some of the bundles.
I cant provide exact example of my BundleConfig, but I will write down an example that is accurate for all bundles.
ScriptBundle sc = new ScriptBundle("~/bundles/sc");
sc.Include(
"~/Scripts/App/Example1.js",
"~/Scripts/App/Example2.js",
"~/Scripts/App/Example3.js",
"~/Scripts/App/Example4.js",
"~/Scripts/App/Example5.js",
"~/Scripts/App/Example6.js",
"~/Scripts/App/Example7.js",
"~/Scripts/App/Example8.js");
bundles.Add(sc.WithLastModifiedToken());
Bundles that do not get minified have only one thing in common. They only have scripts made by us, but we have no errors and warnings are not related to front end. At first i was thinking maybe there are too many js files in the bundles, but one of them has only 3 files and one has 102. Bundles are made but their contents are not minified. Documentation is useless, please help me figure out why cant it minify them.
1- Check the files for syntax errors. The minifier shows unpredictable behaviors when ever it can not minify a file containing an error. One way would be adding files one by one to find which one is causing the problem. In my experience most of the time this happens when very simple problems like semicolon positions in this piece of code:
2- Check the extensions: if any of the files' extension ends with .min.js they would be ignored (even-though not really minified ).