Difference between theme.info and drupal_add_js ( jquery-2.0.3 ) On a fairly new drupal (7.23) site I tried including the jquery-2.0.3.js file with the drupal_add_js function in one of my modules hook_init function.  All was working good and well when I was testing the login screen but then I went to some others pages, I got this error in firebug console:

TypeError: $(...).add(...).filter(...).once is not a function
http://XXX/sites/all/libraries/jquery/jquery-2.0.3.js?mw5wsb
Line 1670

(where XXX is my sitename)

So I noticed on one of my other sites the same library loaded fine when it was included in the theme.info file.  So I tried it that way and sure enough jquery-2.0.3 loads fine when I do it that way.  (ie.    scripts[] = js/vendor/jquery-2.0.3.js

Does anyone know why a jquery include would not work with drupal_add_js and why it would work with the theme.info file?

Many thanks.

d
Generally speaking you should avoid adding third-party libraries directly from your module. If all modules would do that, your site would end up with multiple loads of jQuery/Modernizr/Backbone/etc.
First see if there is an existing module for that, and if not - use Libraries API to declare a dependency in your custom module and then load the script afterwards. This way if some other module depends on the same library and declares dependency through Libraries API, Drupal will load only one file automatically, avoiding conflicts.
For jQuery, check out jQuery Update module. Drupal itself uses jQuery for forms and other elements, so it is not enough that only your module or theme work on the latest jQuery. All core widgets, effects and AJAX calls need to be ported for specific version. That's why  jQuery Update module exists - it upgrades the version of jQuery and loads updated Drupal scripts instead of the original ones, so the site does not break.
Regarding the differences between drupal_add_js() and adding a script filename in the theme.info, here's a summary:


When you add a script to theme.info file, it will be automatically loaded for all pages displayed with your theme. This means that if you are using an administrative theme, such as Rubik, your script will not be loaded on pages where you use that theme.
With drupal_add_js() you can load a JS file only when you need it (e.g. only on certain pages, for certain roles etc.).
drupal_add_js() also provides you with additional functionality, such as inline JS for variables.



Hope this helps.