Вопрос

I have this in the <head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

And this for some fadein/fadeout of text taken from my question

<script>
var $ticker = $('#ticker'); // save the static element
$ticker.children(':not(:first-child)').hide();

function tick(){
$ticker.children(':first-child').fadeOut(1000, function () {
    $(this).appendTo($ticker);
    $ticker.children().first().fadeIn(1000);
});
}
setInterval(tick, 6000);
</script>

And than I use this slimbox

My question(s)!

  • Why do I need to refer to that online link for jquery 1.6.4 on google code? Can I download the jquery.js file and the latest one (i think version 1.8.1) and than refer to it as

    <script src="scripts/jquery.min.js"></script>
    
  • The slimbox says in the Setup to "1. Include the script in the header of your page, after the inclusion of the jQuery library:" but I am not doing that but still my lightbox works. Is it because I am already reffering to it once and don't need to do it again?

    <script type="text/javascript" src="js/jquery.js"></script>
    
  • Should I be using to the latest jQuery and If I do so, will both (the ticker & the slimbox) work?

As per my question, I should not use two jquery versions.

Это было полезно?

Решение

  1. Yes you can but in most cases having it in google repositories is better
  2. Yes it's because you have already done it
  3. Yes you should use it unless there's any incompatibility issues. You can try this for yourself in two minutes

Другие советы

Yes.. You can download the jQuery file and include it in your page as well..

The best reason to use the file hosted by any CDN is that it reduces the bandwidth of your website , as the file will be cached instead of separately loading it after every session..

In this case it is working even if the hosted file is not included is becoz of the copy in your project that you have included..

Make sure you do not include two different copies of the same file , whcih may lead to conflicts ..

Yes, you can download any jQuery version you like and include it from anywhere you like. Consider however that a lot of people will already have the library loaded from a common source, so that it's already in the browser cache.

Generally most things in a newer version is backwards compatible. With basic stuff it works just fine to upgrade to the latest version.

There are many different ways that you can load the scripts, some will work and some wont. The way to do it described in the instructions would be one that has the best chance of working in any situation.

Generally the latest version of a library has the best features and fixes for most known bugs, but sometimes a new version also has bugs that the previous version didn't. I would be more carful to use a new major version (like 1.8.0 or 2.0.0) before it has been out for a while and has been tested in the wild.

No including multiple jquery versions is bad and will cause issues. Include it 1x and be done with it. You can either include locally <script src="scripts/jquery.min.js"></script> or using the cdn <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>. If you are already including it then skip that step in the tutorial.

EDIT:

Per wikipedia: "A content delivery network (CDN) is a large distributed system of servers deployed in multiple data centers in the Internet". Basically you don't need to download the file and host it off your server. Someone else does this for you. Since browsers will limit the number of connections open per domain this allows you a faster download of your site to a client's computer as the CDN is on a separate domain. The CDN in this case is the link https://ajax.googleapis.com/..... I believe you can change 1.6.4 part to 1.8.2 and it should link to that version. But you should check out the google hosted libraries page for more information: https://developers.google.com/speed/libraries/devguide

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top