How does
@Scripts.Render("~/bundles/jquery")
differ from just referencing the script from html like this
<script src="~/bundles/jquery.js" type="text/javascript"></script>
Are there any performance gains?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Bundling is all about compressing several JavaScript or stylesheets files without any formatting (also referred as minified) into a single file for saving bandwith and number of requests to load a page.
As example you could create your own bundle:
And render it like this:
One more advantage of
@Scripts.Render("~/bundles/mybundle")over the native<script src="~/bundles/mybundle" />is that@Scripts.Render()will respect theweb.configdebug setting:If
debug="true"then it will instead render individual script tags for each source script, without any minification.For stylesheets you will have to use a StyleBundle and @Styles.Render().
Instead of loading each script or style with a single request (with script or link tags), all files are compressed into a single JavaScript or stylesheet file and loaded together.