Skip to content

Instantly share code, notes, and snippets.

@mowen
Created August 27, 2011 12:36
Show Gist options
  • Save mowen/1175335 to your computer and use it in GitHub Desktop.
Save mowen/1175335 to your computer and use it in GitHub Desktop.
(defvar mo-script-url-alist
'((jquery . "https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js")
(json2 . "http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js")
(ocanvas . "http://cdnjs.cloudflare.com/ajax/libs/ocanvas/1.0/ocanvas.min.js")
(processing . "http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.2.1/processing-api.min.js")
(prototype . "https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js")
(sizzle . "http://cdnjs.cloudflare.com/ajax/libs/sizzle/1.4.4/sizzle.min.js")
(underscore . "http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.1.7/underscore-min.js")
(underscore-string . "http://cdnjs.cloudflare.com/ajax/libs/underscore.string/1.1.4/underscore.string.min.js")
(waypoints . "http://cdnjs.cloudflare.com/ajax/libs/waypoints/1.1/waypoints.min.js"))
"URLs for loading different JavaScript libraries.")
(defun mo-get-script-url (library)
"Get a script URL for the given library."
(cdr (assoc library mo-script-url-alist)))
(defun mo-script-tag-insert-for-library (library)
(let ((script-url (mo-get-script-url library)))
(concat "var script = document.createElement('script'); "
"script.type = 'text/javascript'; "
"script.src='" script-url "'; "
"head.appendChild(script);" )))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment