1

On one of our pages we have an ungodly amount of jquery shoved into one script tag. I'm trying to clean things up a bit by separating the code into a few individual .js files and using an ASP MVC 4 ScriptBundle.

However, Chrome shows only one script is loading, and that script has a weird name that looks somewhat like a GUID.

enter image description here

If I select this script, I can see that only the first .js file in the bundle loaded. The second file completely missing.

BundleConfig

public class BundleConfig
{
    // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/AgentTransmission").Include(
                    "~/Scripts/AgentTransmission/SetFields.js",
                    "~/Scripts/AgentTransmission/MarketingDivision.js"));
    .
    .
    }
 }

Screen shot of the Scripts folders

enter image description here

.cshtml Create file (View)

@model MonetModelFromDb.Models.AgentTransmission

@{
    ViewBag.Title = "Create new Agent";
}


<div>

  <meta http-equiv="cache-control" content="max-age=0" />
  <meta http-equiv="cache-control" content="no-cache" />
  <meta http-equiv="expires" content="0" />
  <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
  <meta http-equiv="pragma" content="no-cache" />

    <script src="@Url.Content("~/Scripts/jquery.maskedinput-1.3.1.js")" type="text/javascript"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.min.js"></script>
    @Scripts.Render("~/bundles/AgentTransmission")

Rendered HTML

<div>

  <meta http-equiv="cache-control" content="max-age=0" />
  <meta http-equiv="cache-control" content="no-cache" />
  <meta http-equiv="expires" content="0" />
  <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
  <meta http-equiv="pragma" content="no-cache" />

    <script src="/Scripts/jquery.maskedinput-1.3.1.js" type="text/javascript"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.min.js"></script>
    <script src="/bundles/AgentTransmission?v=2D1TPLuuUcxrXmQ8AbdEoyTUVF8BEXja9e0nXKAzs9Q1"></script>

EDIT

FYI I'm also running in DEBUG mode

NealR
  • 10,189
  • 61
  • 159
  • 299
  • 2
    It looks like it's running with optimization on. Do `BundleTable.EnableOptimizations = false` in `RegisterBundles()` to force it into debug. – Jasen Nov 20 '14 at 20:52
  • That worked. If you want to write it up as an answer I'll accept. Thx – NealR Nov 20 '14 at 21:00
  • More complete answers [here](http://stackoverflow.com/questions/11944745/asp-net-bundles-how-to-disable-minification?rq=1) – Jasen Nov 20 '14 at 22:51

2 Answers2

0

When you "Publish" your project and the "Configuration" selected is "Release", the system takes your bundles and combines them into a single file with the "GUID"-like name. If you Publish or Build your project with the "Debug" Configuration, it will leave each individual file in the bundle as a separate file in your HTML.

randyh22
  • 463
  • 4
  • 10
0

Added the following statement to the end of the RegisterBundles() class

BundleTable.EnableOptimizations = false
NealR
  • 10,189
  • 61
  • 159
  • 299