Skip to content

Instantly share code, notes, and snippets.

@jsifalda
Last active December 12, 2015 02:49
Show Gist options
  • Save jsifalda/4702202 to your computer and use it in GitHub Desktop.
Save jsifalda/4702202 to your computer and use it in GitHub Desktop.
Load dependencies by js
var deps = [
'/js/libs/jquery.min.js',
'/js/libs/address.min.js',
'/js/libs/ui.min.js',
'/js/libs/prefixfree.min.js',
'/js/libs/modernizr.js',
'/js/libs/jqtube.js',
'/js/core.js',
'/js/yt.js',
'/js/objects/AjaxRequest.js',
'/js/objects/YouTubeApi.js',
'/js/objects/Youtube.js',
'/js/objects/Storage.js',
'/js/objects/Video.js',
'/js/nette/forms.js',
'/js/nette/ajax.js',
'//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js'
];
var Loader = {
deps: [],
require: function (url) {
Loader.deps.push(url);
},
create: function (url) {
var el = document.getElementsByTagName('body')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
el.appendChild(script);
},
register: function () {
if(Loader.deps && Loader.deps.length > 0){
Loader.deps.forEach(function (url) {
Loader.create(url);
});
}
}
};
(function () {
Loader.deps = deps;
Loader.register();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment