Ideally I'd like the js file containing the plugin also look after including the jquery library.
I've played with a couple of mechanisms without success, XHR script injection and basic script injection like:
myplugin.js:
var scriptElem = document.createElement('script');
scriptElem.src = 'jquery-1.6.1.js';
document.getElementsByTagName('head')[0].appendChild(scriptElem);
(function() {
jQuery.fn.myplugin = function() {
...
}
})();
but of course jQuery won't be defined in time.
Any suggestions?