Skip to content

Instantly share code, notes, and snippets.

@naneau
Created May 7, 2011 15:56
Show Gist options
  • Save naneau/960600 to your computer and use it in GitHub Desktop.
Save naneau/960600 to your computer and use it in GitHub Desktop.
Load google web fonts, in CoffeeScript! :)
# Export Google WebFont Config
window.WebFontConfig =
# Load some fonts from google
google:
families: ['Inconsolata', 'Pacifico', 'Droid Sans', 'Droid Serif']
# ... you can do something here if you'd like
active: () ->
# Create script tag matching protocol
s = document.createElement 'script'
s.src = "#{if document.location.protocol is 'https:' then 'https' else 'http'}://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"
s.type = 'text/javascript'
s.async = 'true'
# Insert it before the first script tag
s0 = (document.getElementsByTagName 'script')[0]
s0.parentNode.insertBefore s, s0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment