Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:58:29+00:00 2026-06-17T18:58:29+00:00

In Summary When bundling and minifying JavaScript, is it good practice to have a

  • 0

In Summary

When bundling and minifying JavaScript, is it good practice to have a single site-wide JS bundle or multiple specific bundles?

If the latter, then how can these bundles be added to each View (not layout) and still get the server to return the individual non-minified JS files when in debug mode?

In Detail

I read a very interesting article detailing how to use the bundling and minification that is available in the MVC4 framework in the an ASP.NET MVC3 web application: click for article

In this article, it describes how to add a link to a particular bundle from the layout page:

Scripts.Render("~/bundles/MyBundle")

And I can see how this approach is great for creating a site-wide bundle.

However, I’m not sure what the best-practice is regarding whether to have a single site-wide bundle, or multiple specialized bundles and I’d appreciate advice here. As I see it, the pros and cons of a single site-wide bundle are:

  • Cons:
    • slows down initial load of home page (even with minimization)
    • may be harder to ensure no JS conflicts.
  • Pros:
    • all subsequent pages have nothing new to download
    • just one bundle to administer

Okay – assuming that best practice turns out to be multiple bundles…. That being the case, I see how easy it is to add a bundle to a layout page, but how about specific views? Each View should register the JS that it requires (in a script section) and then this is added to the bottom of the page’s body so that it loads last (unlike CSS which you add to the Header so that it loads first). I managed this using the following code, but the problem with this route is that the JS always comes out as the single minified file which isn’t that helpful in debug mode.

@<script src="@Scripts.Url("~/bundles/myBundle")"></script>

Many thanks in advance

Griff

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:58:30+00:00Added an answer on June 17, 2026 at 6:58 pm

    You can do both. In order to render the specialized bundles, you can do this:

    Create a scripts section in your _Layout.cshtml. I usually put mine at the bottom of the page just before the closing body tag, but you could also put it in the head:

    @RenderSection("scripts", required: false)
    

    Then, in your view, you define the section like so:

    @section scripts {
    
        @Scripts.Render("~/bundles/myspecialuniquebundlejustforthisview")
    
    }
    

    When you do it this way, the bundle will only be compressed and minified when you either compile with debug=”false” or explicitly set BundleTable.EnableOptimizations = true during debug time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary: I have passed the name of the id select tag into an Array.
Summary : I have a code snippet that compiles fine with g++ but not
Summary I have been looking at historical Australian Rules outcomes using excel with an
Summary I have a web-application with more than 5 themes. Each themes covers a
Summary: I have an ASP.NET MVC website in IIS named 'Website' using an AppPool
Summary: I have a bunch of C functions I have to call from C#.
SUMMARY: I have created a SSRS Report. I want to be able to supply
Summary: Does anyone know what the minimum we have to do is to get
Summary : I have a project using GNU Autotools. I have a pot file.
Summary We have an ASP.NET application that allows users to query a SQL Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.