I'm building a large jQuery widget and I have some scripts I depend on to run this widget. Of course I could just include them in my html page but that not so hot. I need to load them from my widget.
I know about $.getScript but unfortunately it seems like it will run the code after the end } before running what is in it. It also does not cache the scripts which will slow are site down.
I've tried the LazyLoad plugin, same deal as $.getScript(), it will run the code after the function before what's in it.
What I'd like to do is in the _create function I could just call this._dependencies() and load all the required scripts I need and then continue in _create.
Here's some code:
;(function ($, window, document, undefined) {
$.widget("test", {
create: function () {
this._dependencies();
$..setLocale(this.locale);
},
_dependencies: functio() {
LazyLoad.js(['jquery.i18n.js', 'test.i18n.js'], function () {});
}
});
})(jQuery, window, document);