I am trying to write a few small features that basically add layers of convenience to SharePoint pages. These "layers of convience" are basically JQuery wrapped in ScripLink features. For example, I have one that will disable all complex dropdowns on a page using JQuery. I have another one that replaces all Date fields with better Date fields and better date pickers. I have another one that gets rid of those ridiculous dropdowns that they use for Time, that looks like something someone would have written in 1995.
I want all of these features to be self-contained and independent. But I've stumbled upon a few problems.
The first problem is that I don't always know if jquery or jquery-ui is loaded, even if I check for it. For example, in the first feature, I check if (typeof JQuery == 'undefined'), which works fine if the page I'm on includes JQuery. If it doesn't, that's also fine .. I add it. But if I have ANOTHER jquery feature in a scriptlink, it will check if (typeof JQuery == 'undefined') before the first scriptlink has had a chance to add it. Race condition!
The second, and more serious problem, is that a page I'm on has an older version of jquery-ui (1.8.12) which, as far as I can tell, does not support the datepicker I'm using in my Better Date feature. The version I'm using in that feature is 1.10.2. But when the feature runs, and sees that jquery.ui is defined, it doesn't define it. This means that datepicker ends up being undefined.
Is there a better way of defining and registering jquery libraries on a page, so I can sort of mix-and-match whatever JQuery SP features I want on a particular site?