My asp.net MVC4 web project is running very slowly when serving a simple page that renders bundled scripts. However, when I use a 'hardcoded' script tag on the page with the source attribute of the virtual bundle path then performance is much better:
@Scripts.Render("~/bundles/scripts") ~ 4 seconds
vs
<script src='@Scripts.Url("~/bundles/scripts")'></script> < 1 second
My BundleConfig.cs
has no special configuration, this is exactly as it appears:
bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
"~/Scripts/jquery-1.7.2.min.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery-ui-1.9.0.custom.min.js",
"~/Scripts/bootstrap.min.js",
"~/Scripts/bootstrap-modal.js",
"~/Scripts/bootstrap-dropdown.js",
"~/Scripts/bootstrap-tooltip.js",
"~/Scripts/bootstrap-typeahead.js",
"~/Scripts/bootstrap-transition.js",
"~/Scripts/bootstrap-popover.js"));
My web.config
is even configured to optimize in Debug but I have tried running in Release mode and still get the same result:
<compilation optimizeCompilations="true" debug="false" targetFramework="4.0" />
Any ideas why Scripts.Render
is so slow?
The problem was with the outdated package I had installed. A simple Update-Package
in package manager console and I went from
<package id="Microsoft.AspNet.Web.Optimization"
version="1.0.0-beta2" targetFramework="net40" />
to
<package id="Microsoft.AspNet.Web.Optimization"
version="1.0.0" targetFramework="net40" />
Now Scripts.Render()
is peforming much better :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With