Let’s go over these steps in more detail. Add a reference to your bundle to your MVC views.Register your bundle configuration with your Web application.Create a bundle configuration to instruct MVC how to combine and compress (minify) your files. To get started with bundling in MVC4, you’ll need to perform a few straightforward steps: The server component of the application, written in ASP.NET MVC 4, provided us with an excellent way of providing bundled, minified scripts with its built-in bundling feature. Though the application we developed was quite complex (and featured about two dozen external script files), it was targeted at iPad users, among others, and therefore needed to load quickly, even over a slow cellular network. In a project we recently completed at Headspring, a coworker and I encountered this problem quite early. Many also perform a process known as “minification”, whereby non-essential whitespace is removed and variable names are changed to be as short as possible, resulting in an unreadable-but highly efficient-piece of code. To combat this problem, developers often use tools called “bundlers”, which concatenate script files-or stylesheets-together into a single file, thereby reducing the I/O overhead of sending multiple files across the Internet. Start with jQuery and some application libraries like Backbone.js (and its dependency, Underscore), then throw in plugins from UI frameworks like Foundation and some form validation scripts-not to mention your app’s code itself!-and you can easily discover your app has dozens of external files, each of which must be loaded on every page refresh. Regardless of the approach that you choose, bundling and minification can translate into smaller requests and quicker load times for your users and as demonstrated here, it hardly takes any work at all.A Quick-Start of ASP.NET MVC 4's BundlingĪs a Web application becomes more complex, the number of external scripts on which it depends grows significantly. While bundling and minification may be a bit different than you may have been accustomed to, it's going to be one of the smaller things that you have to worry about transitioning to this new modular ASP.NET Core world. Select your preferred binding from the Bindings context menu.Right-click on the Update All Files option below bundleconfig.json.Open the Task Runner Explorer (via Tools > Task Runner Explorer). " To do this, you'll need to do the following: " outputFileName": " wwwroot/app/bundle.js", You'll then notice a new file within your project called bundleconfig.json which looks like the following: This will prompt you to name your bundle and choose a location to save it at.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |