Installing jQuery?

Jquery

Jquery Problem Overview


What is the procedure for installing jQuery for someone new to it?

Jquery Solutions


Solution 1 - Jquery

Get jQuery up and running in a minute or less:

Insert this into your HTML (most commonly in the head, but you can throw it before the end body tag too):

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

Then place a script element after your jQuery one. This would alert 'hello' after the DOM is ready.

<script>$(function() { alert('hello') });</script>

Read the documentation.

Using jQuery locally:

After you get a feel, try downloading jQuery locally to your computer, and link it from your script file. The structure is like so:

C:/web/index.html
C:/web/js/jquery.js

index.html:

    <head>
        <script src="js/jquery.js"></script>
        <script>$(function() { alert('hi') })</script>
    </head>

You have the advantage of relying on your saved version offline if you don't have the Internet/Wi-Fi. You can also make custom edits to the jQuery source and modify it at will.

Study the jQuery source [advanced]

Download the uncompressed version from:

http://code.jquery.com/jquery-latest.js

After you've gained a bit of JavaScript/DOM knowledge try to take it apart step by step.

Solution 2 - Jquery

There is no installation per se.

You download jQuery and include it in your html files like this:

<script src="jquery.js" type="text/javascript"></script>

Of course, modify the filename so that it's the same as the downloaded script file.

Done!

Solution 3 - Jquery

The following steps can be followed

  1. Download Jquery by clicking on this link DOWNLOAD

  2. Copy the js file into your root web directory eg. www.test.com/jquery-1.3.2.min.js

  3. In your index.php or index.html between the head tags include the following code, and then JQuery will be installed.

Solution 4 - Jquery

It tells you at the very start of the tutorial linked from the jQuery homepage.

Solution 5 - Jquery

There is none. Use script tags to link to google's version (or download it yourself and link to your copy if you really want to).

If you don't know how to do that, learn HTML and Javascript first before attempting to learn jQuery.

Solution 6 - Jquery

The best thing would be to link to the jQuery core is via google.
There are 3 reasons to do it this way,

  • Decreased Latency
  • Increased parallelism
  • Better caching
      see:
      http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
 $(document).ready(function() {

Your code here.....

  });
</script>

Solution 7 - Jquery

There is no installation required. Just add jQuery to your application folder and give a reference to the js file.

<script type="text/javascript" src="jQuery.js"></script>

if jQuery is in the same folder of your referenced file.

Solution 8 - Jquery

There are two different ways you can utilize jQuery on your website. To start off, you need to have access to your website source, whether it be straight HTML or generated HTML from a programming language. Then you need to insert a <script> tag that will render in the final output to the web browser.

Because you are new to jQuery, I highly suggest you start reading How jQuery works.

As others have mentioned, there are Content Distribution Networks (CDNs) that host JQuery -- all you need to do is point your script tag src to a specific URI. Google and Microsoft both have CDNs that are free for personal and commercial use.

Alternatively, you can download jQuery and host it on your own website.

You can also leverage both of these methods together. In the event that the Google or Microsoft CDN is down or blocked in the end user's country/firewall/proxy, you can fallback to your locally hosted copy of jQuery.

Solution 9 - Jquery

Install JQuery with only JavaScript. This is not a very good solution if you are developing a website but it's great if you want JQuery in the JavaScript console of a random website that does not use JQuery already.

function loadScript(url, callback)
{
    // adding the script tag to the head as suggested before
   var head = document.getElementsByTagName('head')[0];
   var script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = url;

   // then bind the event to the callback function 
   // there are several events for cross browser compatibility
   script.onreadystatechange = callback;
   script.onload = callback;

   // fire the loading
   head.appendChild(script);
}
loadScript("http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js")

loadScript function thanks to e-satis's answer to Include JavaScript file inside JavaScript file?

Solution 10 - Jquery

As pointed out, you don't need to. Use the Google AJAX Libraries API, and you get CDN hosting of jQuery for free, as depending on your site assets, jQuery can be one of the larger downloads for users.

Solution 11 - Jquery

jQuery is just a JavaScript library (simply put, a JavaScript file). All you have to do is put it into your website directory and reference it in your HTML to use it.

For example, in the head tag of your webpage

<script type="text/javascript" src="../Js/jquery.js"></script>

You can download the current jQuery release from Downloading jQuery.

Solution 12 - Jquery

Well, as most of the answers pointed out, you can include the jQuery file locally as well as use Google's CDN/Microsoft CDN servers. On choosing Google vs. Microsoft CDN go Google_CDN vs. Microsoft_CDN depending on your requirement.

Generally for intranet applications include jQuery file locally and never use the CDN method since for intranet, the LAN is 10x times faster than Internet. For Internet and public facing applications use a hybrid approach as suggested by cowgod elsewhere. Also don't forget to use the nice tool JS_Compressor to compress the extra JavaScript code you add to your jQuery library. It makes JavaScript really fast.

Solution 13 - Jquery

There are two ways to load jQuery in your application:

  1. Add jQuery from your own site.

For this, you need to add jQuery reference in <Head> section of your page with correct src path:

<script src="script/jquery.js" type="text/javascript"></script>

But this create an additional load to your server for download a file to client

  1. ther other way to load jQuery from any other server like Google, Microsoft or jQuery itself.

As stated here:

> it provides several advantages. > > 1. You always use the latest jQuery framework. > 2. It reduces the load from your server. > 3. It saves bandwidth. jQuery framework will load faster from these CDN. > 4. The most important benefit is it will be cached, if the user has visited any site which is using jQuery framework from any of these > CDN.

Here is the link by which you can load jQuery from Microsoft. Follow this url, it may be helpful.

http://www.asp.net/ajaxlibrary/cdn.ashx

Solution 14 - Jquery

If you want to use a package manager,

You can use bower:

bower install jquery-ui

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHariharbalajiView Question on Stackoverflow
Solution 1 - Jquerymeder omuralievView Answer on Stackoverflow
Solution 2 - JqueryChristian DavénView Answer on Stackoverflow
Solution 3 - JqueryElitmiarView Answer on Stackoverflow
Solution 4 - JqueryQuentinView Answer on Stackoverflow
Solution 5 - JqueryMachaView Answer on Stackoverflow
Solution 6 - JqueryadardesignView Answer on Stackoverflow
Solution 7 - JqueryrahulView Answer on Stackoverflow
Solution 8 - JquerycowgodView Answer on Stackoverflow
Solution 9 - JqueryNateView Answer on Stackoverflow
Solution 10 - JqueryMarc BollingerView Answer on Stackoverflow
Solution 11 - JqueryScottView Answer on Stackoverflow
Solution 12 - JqueryA_VarView Answer on Stackoverflow
Solution 13 - JquerymayankView Answer on Stackoverflow
Solution 14 - JqueryXoXoView Answer on Stackoverflow