Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is using "jquery-latest.min.js" bad practice?

So the title says it. Is it bad practice to use <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> when I want to include Jquery in my page?

I asked this question because nowhere in the Jquery, Google, and Microsoft websites they provide such a link. Rather they put versioned links like this <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>. That's why I thought maybe they do not want people to use that link.

And if it is bad practice, why is that? and what is the solution to keep up with these version changes?

like image 592
Reza Avatar asked Feb 14 '23 11:02

Reza


1 Answers

Using a "latest" jQuery in a production environment wouldn't be very smart, as your web site would stop working if breaking changes occur. You always want to know which jQuery version you are writing your web site's code against.

Updating to a new jQuery version should always be a manual process for that reason. It would ideally look something like this:

  • Look at the change log or upgrade guide of the new version (example)
  • Fix any issues in your code that the new version might cause
  • Start using the new version on an internal / development version of the web site
  • Test it thoroughly
  • When all is well, switch the production site to using the new version.
like image 53
Pekka Avatar answered Feb 17 '23 01:02

Pekka