 
       setTimeout ->
         bar.finish()
-      , Math.max(GHOST_TIME, Math.min(MIN_TIME, now() - start))
+      , Math.max(options.ghostTime, Math.min(options.minTime, now() - start))
     else
       enqueueNextFrame()
 
-do check = ->
+Pace.start = ->
   bar.render()
 
   # It's usually possible to render a bit before the document declares itself ready
   if not document.querySelector('.pace')
-    setTimeout check, 50
+    setTimeout Pace.start, 50
   else
-    go()
-
+    Pace.go()
+
+if typeof define is 'function' and define.amd
+  # AMD
+  define -> Pace
+else if typeof exports is 'object'
+  # CommonJS
+  module.exports = Pace
+else
+  # Global
+  Pace.start()

class Scaler
  constructor: (@source) ->
    @last = @sinceLastUpdate = 0
    @rate = 0.03
    @catchup = 0
    @progress = @lastProgress = 0


  else
    obj[key]

extend = (out, sources...) ->
  for source in sources when source
    for own key, val of source
      out[key] = val
  out

getOptionsFromDOM = ->
  el = document.querySelector '[data-pace-options]'
  data = el.getAttribute 'data-pace-options'
  
  try
    return JSON.parse data
  catch e
    console.error "Error parsing inline pace options", e

window.Pace ?= {}
Pace.options ?= {}

options = extend Pace?.options, getOptionsFromDOM(), defaultOptions

class Bar
  constructor: ->
    @progress = 0
