The jQuery framework is part of nearly all the Visual Studio web project templates. This includes the readable version of the file (useful for debugging) jquery.js
and the minified version (for faster processing in production) jquery-min.js
. Recall from Chapter 17, “Building Modern Websites with ASP.NET 5” that these files are stored in the bower_components
folder of the ASP.NET 5 Web Site template and end up in the wwwroot/lib/jquery
folder. Chapter 17 also introduced Bower and the bower.js
file for including client scripts in your project. The ASP.NET 5 template uses this approach to include jQuery in the project.
Recall from the prior section that you need to add a reference to your page for any JavaScript files you intend to use. Again, you do this using the <script>
tag at the bottom of your HTML markup, before the closing </body>
tag.
Of course, adding this reference to every page in your site can be tedious. Chapter 17 also introduced the concept of the _Layout.cshtml
page in your project. Recall that this page controls common layout items for each page in the ASP.NET 5 MVC 6 template. Thankfully, this page also includes the jQuery <script>
tags based on deployment environment, as shown in Figure 18.5. This means all your pages in the site that use _Layout.cshtml
already have access to jQuery.