How to add jQuery to Web Pages: MVC

September 20, 2014 , , 0 Comments

Programmer must include jQuery library on the web pages (views in case of MVC) to be execute all the functions/event/triggers written for that page in jQuery.  This article will lists all the options may be used to use jQuery on the pages.

To include jQuery there are two options which are basically used:
  • Include jQuery from google
  • Download and then add a reference on your page. (

All the js files have two versions and can be downloaded through the website given above:
  • Development version:  uncompressed and readable, used for testing purpose
  • Production version: compressed and not readable, used on live sites.


In earlier article, we have studied about layout files and a simple view file that is used to render styles/scripts on the pages in MVC. So to include jQuery or any other file on the page we have two ways i.e.
  • Add reference on view: adding a reference on the view individually will only enable jQuery for that page. If you want to use it on another page then you have to add it on that page also.
  • Add reference on layout: as we all know, layout file is the basic structure for all the pages including that layout. So adding a reference on layout can be used for all the pages following that layout.

Earlier article was about to use selectors on the page but without adding this reference, you can’t use those. In next article we will discuss about jQuery syntaxes.

Subhash Sharma

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google