0

I don't know how to ask the question for the confusion I am having. Currently I am working on an already developed MVC5 project. In which I have seen that on layout page, bootstrap bundle is added and when I check bootstrap bundle code, it is having both minified and non minified js reference like below:

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/bootstrap.min.js"
                      ));

I don't know if it is required to add both? Will it create any problem? What happen in case of CSS when both minified and non minified files added?

3
  • Is the included code just libraries or is it actually calling functions? If functions are being called, then they will all be called twice, but it is only setting functions and/or variables, then it shouldn't cause any problems but one or the other should be removed for performance reasons Commented May 27, 2014 at 4:25
  • @stumpx, thanks. I was wondering that why some of my calls become twice. i will remove non minified. I just want to know this things happen for css too? Commented May 27, 2014 at 4:30
  • Since CSS doesn't do anything except define I couldn't imagine it would, but I would just for, again, the performance benefits. Commented May 27, 2014 at 4:36

3 Answers 3

1

You should not use both the files at the same time

While working on the code(Debug mode) use the non minified version or the even the debug version if available as it will help to find out errors easily.

And when deploying the application use the minified version as the file will be lighter and will be loaded fast.

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

2 Comments

What happen in case of css?
same with the CSS. both files are not used.
0

No, it is not require to add both the files. if you add both, it consider the last file. i suggest you to create two different bundle for production and development, and just switch the flag when you want to upload to production.

Comments

0

It never requires to add both the file further down the line It depends on your requirement. They are both the same functionally but the .min one has all unnecessary characters removed in order to make the file size smaller. If you want to edit the bootstrap js keep non-minified js in project as mini JS can't be modified or understood. And if you are not modifying any js just keep the mini version. Mini js offers loads of benefits over its original format(non-mini). See :

  1. Quicker download times for your users.
  2. Reduced bandwidth consumption of your website.
  3. Reduced number of HTTP requests on your server when combining many javascript files into one compressed file, thus reducing the server load and allowing more visitors to access our website.
  4. Comments and whitespace are not needed for javascript execution; Removing them will speed up script execution times.

Although Bootstrap offers custom js creation so If you see you project changes demands mini js(for faster execution and several other benefits) just go on their site and modify your js.

Note : Just to point out as well, you are better using the minified version (.min) for your live environment as Google are now checking on page loading times. Having all your JS file minified means they will load faster and will score you more brownie points.

You can get an addon for Mozilla called Page Speed that will look through your site and show you all the .JS files and provide minified versions (amongst other things).

Comments

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.