Last active
December 12, 2015 02:49
-
-
Save jsifalda/4702202 to your computer and use it in GitHub Desktop.
Load dependencies by js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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