Permalink
Browse files

Add load script utility

  • Loading branch information...
Koen Bok
Koen Bok committed May 12, 2013
1 parent 8a8f4ae commit 3e381c6a5232ca7a3e6410ca939a6d10414ec2f4
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/utils.coffee
View
@@ -315,8 +315,10 @@ exports.isMobile = ->
navigator.userAgent.toLowerCase()
# Public: Only executes a given function if the dom is loaded
#
######################################################
# DOM FUNCTIONS
__domComplete = []
document.onreadystatechange = (event) =>
@@ -334,6 +336,19 @@ exports.domCompleteCancel = (f) ->
__domComplete = _.without __domComplete, f
exports.domLoadScript = (url, callback) ->
script = document.createElement "script"
script.type = "text/javascript"
script.src = url
script.onload = callback
head = document.getElementsByTagName("head")[0]
head.appendChild script
script
######################################################
# POINT FUNCTIONS

0 comments on commit 3e381c6

Please sign in to comment.