Questions tagged [scriptbundle]

Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP requests and that can improve first page load performance.

Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP requests and that can improve first page load performance.

38 questions
15
votes
3 answers

How is {version} value being populated in BundleConfig file?

I recently added jquery.dataTables nuget package to my project and I wanted to bundle the necessary files inside the BundleConfig. Since this package is installed inside a "DataTables-1.9.4" folder within Scripts folder I added the following line to…
Marko
  • 12,543
  • 10
  • 48
  • 58
10
votes
1 answer

Is there an easy way to render absolute URLs with Microsoft Web Optimization framework / script bundling?

I'm trying to render a JavaScript bundle using Microsoft's Web Optimization framework, like this: @Scripts.Render("~/assets/bundle.js") And building a small bundle, like this: public static void RegisterBundles(BundleCollection bundles) { …
Brandon Linton
  • 4,373
  • 5
  • 42
  • 63
9
votes
1 answer

ASP.NET MVC Script bundle not rendered

I've included the following line in the BundleConfig.cs file: bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include( "~/Scripts/jquery.unobtrusive-ajax.min.js")); However when I try to render it among other scripts, it's skipped. Here is…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
5
votes
3 answers

asp.net scriptbundle multiple include vs single include

What is the difference in bundling: bundles.Add(new ScriptBundle("~/bundles/jquery") .Include("~/Scripts/jquery-{version}.js","file2.js", "file3.js")); vs bundles.Add(new ScriptBundle("~/bundles/jquery") …
HelloWorld
  • 4,671
  • 12
  • 46
  • 78
4
votes
0 answers

ScriptBundle says Object reference not set to an instance of an object

In the Asp.Net MVC BundleConfig if i use ScriptBundle it shows below error for this code: Code: bundles.Add(new ScriptBundle("~/node/GobiJs").Include( "~/node_modules/...../test.js" )); Error: But if i use Bundle instead of…
Arif
  • 6,094
  • 4
  • 49
  • 81
4
votes
2 answers

ScriptBundle with additional attributes

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…
iLemming
  • 34,477
  • 60
  • 195
  • 309
3
votes
2 answers

Why do my script bundles load with every page view in ASP.Net MVC?

I'm a little confused. I have my _layout.cshtml page below and it has a bunch of bundles containing .css and .js files. When I first load the site it runs through each file in the bundles. Fine, OK, great! But then on each new view, each line of…
chuckd
  • 13,460
  • 29
  • 152
  • 331
3
votes
2 answers

is it possible to include Scripts and Styles in same Bundle ?(asp.net mvc5)

Attempting to use css and js files with same virtualpath bundle name 1 - is it possible ? (tried:but failed. cant define same virtual path name both for script and style) 2 - it it possible to builtup a ScriptAndStyleBundle together included…
3
votes
0 answers

StackOverflow in ScriptBundle .NET VS2013

We are experiencing a StackOverflow exception in VS2013 using: var importedTypesBundle = new ScriptBundle("~/ImportedTypes/all.js"); Replacing with Bundle() it works... but it does not minify. It looks the mifinier is not happy about some js file.…
Robert
  • 872
  • 1
  • 8
  • 24
3
votes
1 answer

MVC 4 Styles.Render & Scripts.Render Clarification

I'm using ASP.NET MVC 4 with Bootstrap and I've noticed that my project is a little bit different from a lot of articles and tutorials about "building your site with Bootstrap", they keep mention the use of minified files of Javascript and CSS…
Ron
  • 1,744
  • 6
  • 27
  • 53
3
votes
1 answer

MVC 4: Force ScriptBundle to return non-optimized links of Javascriptfiles

We are trying to get the ScriptBundle in MVC 4 to return the expanded list of javascript when debug = false in the web.config. By default the ScriptBundle will optimize the javascript into one call when debug=false. Currently when you set…
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
2
votes
1 answer

C# MVC StyleBundle and ScriptBundle do not render correct paths if project is run in subdirectory

I have this code in BundleConfig.cs which simply includes a script bundles.Add(new ScriptBundle("~/bundles/ui-scripts").Include( "~/Scripts/ui-scripts.js")); On my locale machine (http://localhost:57210/) this renders out…
CyberProdigy
  • 737
  • 9
  • 20
2
votes
1 answer

ASP.NET MVC 5 bundled scripts not being called in _Layout.cshtml

Before I start let me say that I know there are other questions on SO about this issues that have great answers but please let me explain how mine is different. I have an ASP.NET MVC 5 project where I have a collection of bundles: public class…
AnonDCX
  • 2,501
  • 2
  • 17
  • 25
2
votes
1 answer

ASP.NET MVC Bundling Subfolders structure

I want to include javascript files from whole folder and subfolders into a single ASP.NET Bundle. The purpose of this is to load all files from that folder at once. The idea is to create an angular application and load all app files with a single…
Bogdan Beda
  • 758
  • 5
  • 12
2
votes
0 answers

MVC4 Why have separate script bundles

This is just for interest sake. Why does the vanilla MVC template in VS split the script bundles into ScriptBundle("~/bundles/jquery") and ("~/bundles/jqueryval") I realize that most pages won't need the jqueryval bundle, but minified its so small…
Swifty
  • 1,422
  • 2
  • 18
  • 38
1
2 3