3

I use JS here and there mainly for slideshows, form validation, drop down sitenav (next step) but I have a few noobie questions if some one has the time...

I have been able so far just to use a jquery library on my server but recently start using a calendar for clients to select a date of birth. The calendar required these sources.

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

My instinct tells me I should have these .js and .css files on my server, is it bad practice to use http sources? I'm currently keeping the links because I need to reference these libraries from different directories of my site.

Are these jquery plugins or is it Ajax? as they're not in the main jquery library. I thought Ajax was an MS alternative to JQuery but now I'm confused... Is there a common large library people like to use or is it common to just add smaller ones here and there?

Any help much appreciated.

JohnP
  • 47,501
  • 10
  • 101
  • 134
notidaho
  • 576
  • 8
  • 25
  • 2
    This should help you a bit: http://en.wikipedia.org/wiki/Ajax_%28programming%29 . Ajax is not MS specific and jQuery is not a substitution for Ajax (in fact, jQuery simplifies the use of Ajax). – Felix Kling May 27 '11 at 11:30

3 Answers3

3

What you're doing is actually the preferred option. Serving content via a CDN will (generally) make page loads faster for your users. Just make sure you have some kind of backup code in case the CDN goes down.

As to the second part of your question. Javascript is a language. jQuery is a framework built on top of Javascript and Ajax is a technique that is used in Javascript to make page more interactive. They are related, but are not alternatives to each other.

Further reading

jQuery via Google CDN best practices

jquery from cdn

Microsoft CDN for jQuery or Google CDN?

Community
  • 1
  • 1
JohnP
  • 47,501
  • 10
  • 101
  • 134
3

Actually using the google code repository like this has some advantages over storing these files on your own server. For one thing, it might speed up the client because some folks will not have to download the js files since their browser would have cached these files on previous use.

jQuery is a library of functions for making cross browser javascript including AJAX easier. AJAX is a technique for asynchronously requesting server side resources. It is not equivalent to jQuery.

You have included the core jquery library and the jquery UI library in the code snipet that you provided. This is common. In addition there are hundreds of plugins that you optionally can include as needed.

Vincent Ramdhanie
  • 98,815
  • 22
  • 134
  • 183
  • well I can't thank you all enough for your detail straight forward replies. I think I'm a little clearer on definitions and where to look for more info. Glad to hear I'm using the preferred option. I'm abit wary of them CDN links and my clients not being able to enter dates. I'll make sure they can enter manually until I have time to fix any links then. Thanks again, Ian – notidaho Jun 07 '11 at 15:27
1

You are really confused re: AJAX vs jQuery. AJAX is short for Asynchronous JavaScript And XML (although today the XML portion is usually replaced with JSON). In essence, it allows JavaScript to send requests to the server and handle the response to those requests without requiring a new page load. This is facilitated by the XMLHttpRequest JavaScript object which does most of the heavy lifting. AJAX was originally developed/discovered by Microsoft. For more info, see: http://en.wikipedia.org/wiki/Ajax_%28programming%29

jQuery is a different beast altogether. It's a JavaScript framework which focuses on streamlined DOM manipulation through use of its CSS selector engine, simplifying AJAX itself, and otherwise equalizing things across browsers. It's not an alternative for AJAX.

Major Productions
  • 5,522
  • 10
  • 63
  • 138