Skip to content

Instantly share code, notes, and snippets.

@kissarat
Created March 7, 2013 08:23
Show Gist options
  • Save kissarat/5106433 to your computer and use it in GitHub Desktop.
Save kissarat/5106433 to your computer and use it in GitHub Desktop.
function loadLibrary(url) {
script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', url);
document.head.appendChild(script);
}
function loadLibraryByName(name) {
switch(name) {
case 'underscope':
loadLibrary('http://underscorejs.org/underscore-min.js');
break;
case 'backbone':
if (!_)
loadLibrary('http://underscorejs.org/underscore-min.js');
loadLibrary('http://backbonejs.org/backbone-min.js');
break;
case 'jquery':
loadLibrary('http://code.jquery.com/jquery-1.9.1.min.js');
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment