8

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?

1 Answer 1

4

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 :-)

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

6 Comments

On 1.1.0 and seeing some insanely large load times for script bundles (10 .js files)... Consistently getting 7-9 seconds... anyone else?
I have this issue as well. Have you found a solution for this?
Same here, this issue is driving me crazy, any solution?
I have a new package, but it's still slow. Any suggestion? <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
I have the exact same problem with the version 1.1.3 of Microsoft.AspNet.Web.Optimization package
|

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.