RequireJS for .NET brings asynchronous JavaScript loading and flexible js bundling configuration to ASP.NET MVC projects.

RequireJS is an implementation of Asynchronous Module Definition (AMD) that provides all the tools you need to write modular JavaScript. If you are working on a large project with a lot of JavaScript code, many external components and frameworks, RequireJS will help you manage the complexity of dependencies.

Writing modular JavaScript is the first step in bringing the front-end development closer to the server-side OOP, for a C# programmer, the Module Pattern applied to JavaScript means that you can emulate the .NET class behaviour by having public/private members and methods. With RequireJS you can go even further, by declaring a module you can specify dependencies to other modules, the same way as you do in a .NET project when you add references to other .NET components. Before a module is loaded by the browser, RequireJS will look for the dependencies required by that module to function, it will fetch asynchronously from the server, all the other modules needed and then will let the browser execute your module code. RequireJS.NET helps you structure the JavaScript code in such a manner that any C# programmer can understand and use it without advanced js programming skills.

Advantages of using RequireJS with ASP.NET MVC:

  • better JavaScript code re-usability
  • reliable object and dependency management
  • suitable for large and complex applications
  • loads JavaScript files asynchronously

The .NET implementation has the following features:

  • JavaScript file structure integrated with the MVC structure
  • dependencies declaration and module path configuration using JSON or XML
  • JavaScript code-behind for each Razor view
  • Passing values between ASP.NET and JavaScript
  • bundling and minification with RequireJS.NET Compressor and MsBuild
  • internationalization support for JavaScript resources with ResxToJs

License: RequireJS.NET is an open source project released under the terms of the MIT and GPL licenses. You are free to use RequireJS.NET in any project (including commercial projects) as long as the copyright header is left intact.

Documentation: Get started with RequireJS.NET setup tutorial, bundling and compression, i18n support, for the extended documentation check out the wiki.
If you are not familiar with RequireJS and AMD take a look at requirejs.org.