Smokey
Smokey

Reputation: 117

JQuery and Scripts within the head of a document

I have the following scripts listed in my header from various widgets within my website:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

Jquery and using library scripts is new to me (using my own js files are not) the first two lines of the scripts above are similar. Can someone please explain if I need 1.4.1 as I have 1.9.0 - looking at it I would assume it is a later version of 1.4.1.

However removing it; my website does not work correctly so are these a plugin's or widget identification for individual items and the jquery.min.js is a common filename?

My second part of the question, I see Goggle API's, AJAX and code.jquery; are these large library's I should use to find plugin's? Should I rely on those websites or should I download these scripts and place on my server (could that possibly be breaching their usage?). Or do web developers just rely on the above?

Thank you

Upvotes: 0

Views: 93

Answers (1)

Giovanni
Giovanni

Reputation: 838

You have 3 links to the same resource (although different versions). You just need one link to a jquery file, and the later the better.

My suggestion is to not use a version number at all and link to something like this:

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

This way you are always connected to the latest version of jquery. There is no issue at all having the file on your server instead but as mentioned above, you wont get the latest version when it is updated whereas using the link above you will.

Finally with regards to features not working when you remove the older filename, you might be using deprecated features - updating your code which uses jquery will solve this.

Hope this helps!

p.s. There is a migration tool which helps move from an older version of jquery to a newer one - try linking to jquery migrate in your header (make sure its below the main jquery link!) as it is used to detect and restore APIs or features that have been deprecated in jquery and removed up to version 1.9. So in all you will have:

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

p.p.s. The 4th link you have is to jquery ui which is different from jquery - its basically a set of user interactions and effects which are built on top of the basic jquery code. See the jueryui.com website for more information about jquery ui.

Upvotes: 2

Related Questions