When jQuery stops working

When jQuery stops working

One day, suddenly, our website goes down . The sliders do not move, the animations are problems, emerging submenus do not emerge … And all for what? Wait, you’re not using jQuery libraries linked Google CDN ? Ah, bird!

Recently, jQuery has been updated to version 1.9 . Any updating of software such as jQuery involves two sides: new features and functions that are eliminated . With new there is usually no problem, no one was using before. The problem comes with the old.

For example, if you’re one of the lucky ones I used $. browser in your scripts javascript / jQuery, and also Google CDN babies without using a specific version (with a 1 in the url), you’re in luck: all your scripts are failing now.

I’m not against the Google CDN libraries, just saying that jQuery does not weigh as much as for us to consider really having to include it «from outside». Why not download it, put it in a folder / js and link directly from that folder on our server? It has many advantages:

  • Your job does not depend on others . This client facing a crucial, control of your work, how your system behaves. It depends on what others do with trying to upload files, or servers that fall … Can you imagine that someone gets hack Google CDN (well, it is a course, think Murphy’s Law and you are working on for a client), change the files, and instead of jQuery school you anything in your site?
  • It is faster to load from the same server.

Why then load it from outside? Does your building burns down and you’ll find a fire extinguisher next block?It makes more sense to have one point controlled and your block, right?

Well, if you are very very very convinced of the reliability of loading jQuery from Google … Then I suggest you definais the version you want to use. If you do just this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript">

Load the latest version of jQuery available. When after a while take out a new version, this url will load the new, and therefore, I find errors (which is what is happening now). Instead, if we use version 1.8.3, for example, we define this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript">


Thus, changing the 1 per 1.8.3, we know that we are using the version that is compatible with our system, and that while Google update its files, you’ll still be using the best of all: the one that fits your system without causing problems . In the face of a client this is crucial.

And if what you want is to always use the latest version, then you will have to be corrected with each release all errors that arise.

What about you? Do you use Google Hosted libraries Libraries, or prefer download to your server? Why?The debate is:)

«Any fool can write code that a computer understands. 
Good programmers write code that humans can understand. » 
– Martin Fowler

¿Te ha gustado el artículo?
Sé el primero en calificar esta publicación.
1 estrella2 estrellas3 estrellas4 estrellas5 estrellas

Suscríbete. Déjanos tu email y recibe contenido genial cada mes

Artículo escrito por

¡Exprésate! Dejanos tu comentario

Tu dirección de correo electrónico no será publicada.

Aún no hay comentarios en esta entrada. ¿Te animas?