JQuery

Part II – Setting up JQuery

For Part I Please click following link

Considering you have are already downloaded JQuery files (see note below) from JQuery website or you have Microsoft or Google CDN (Content Distribution Networks) link (more on this below in this post). The first thing you need to do for using JQuery is setting up JQuery reference in the Html document / Razor view (ASP.NET MVC – we are not discussing about _layout.cshtml).

  • To reference JQuery in html document – you the script tag in the Header of the Html document .

<head>  <title>Example</title>  http://jquery-1.7.js  <link rel=”stylesheet” type=”text/css” href=”styles.css”/> </head>

  • Using CDN link to reference JQuery in HTMl documents ( see notes for CDN pros and cons).

<head> <title>Example</title> http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js <link rel=”stylesheet” type=”text/css” href=”styles.css”/> </head>

Note:

  • When you download the jQuery files from website mentioned above – you get 2 files.  The first is jQuery-[x.x].js, (x.x -is the version number) file, its the uncompressed version and usually used for development and the second file is the minified vesion (.min.js) –  jquery.[x.x].min.js (x.x is the version number). minified version means –  It contains the same JavaScript code but has been minimized, meaning that all of the white space characters have been removed, and the meaningful variable names have been replaced with single-character names to save space. The minimized script is almost impossible to read for the purposes of debugging, but it is much smaller.
  • More on CDN pro and cons .. later..

Happy Learning.

Leave a Reply