Skip to content

Commit

Permalink
Add load script utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Bok committed May 12, 2013
1 parent 8a8f4ae commit 3e381c6
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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
Expand Down

0 comments on commit 3e381c6

Please sign in to comment.