I want to use jQuery in an add on JS library that can be added to random websites. These websites may or may not use jQuery already.
I have 3 questions around this a
You can try the solution in the following link if it works for you. Basically, there is a plugin that creates widgets on the fly and then asynchronously requests another page url, and sets the returned content as inner html of the widget.
http://sites.google.com/site/spyderhoodcommunity/tech-stuff/jquerydashboardwidgetplugin
This is pretty loose and incomplete -- and really is meant to be a starting point:
if (typeof $ != 'undefined') {
var msg = 'This page already using jQuery v' + $.fn.jquery;
} else {
var s = document.createElement('script');
s.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js');
document.getElementsByTagName('head')[0].appendChild(s);
var msg = 'This page is now jQuerified';
}
then wait via a brief setTimeout() before running a ready() function