9

I've registered bundle in BundleConfig like this: bundles.Add(new ScriptBundle("~/bundles/jqueryupload").Include( "~/Scripts/jquery.upload-1.0.2.min.js"));

And want to render it on the view like this: @Scripts.Render("~/bundles/jqueryupload")

But my sript is not included in the page. Any thoughts? Thanks!

1 Answer 1

22

Do not include minified versions in your bundles:

ScriptBundle("~/bundles/jqueryupload").Include("~/Scripts/jquery.upload-1.0.2.js"))

The whole point of the bundles is that they will take care of minifying and combining your static resources. You shouldn't register a .min.js in your bundles.

Sign up to request clarification or add additional context in comments.

5 Comments

Can you post the example of registering .min.js files in the bundles?
Where is the best place to register .min files in bundles.What is the best approach?
As I already explained in my answer you should not be attempting to register such minified scripts with your bundles. Just include them as normal <script> includes. Or get a non-minified version that you could register with your bundles.
I think, possibly, what the OP was getting at in the follow up comment/question was how do you get the @Scripts.Render to render the minified version of the scripts. In which case the answer is that in release builds it will use file name conventions to find the min version. Or you can use BundleTable.EnableOptimizations = true; when configuring the bundles. If there is no minified version found then it will minify the file for you.
i used ScriptBundle for bundling CSS and got this error , Be sure to use ScriptBundle for Scripts and StyleBundle for CSS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.