Skip to content

Instantly share code, notes, and snippets.

Created Oct 23, 2013
What would you like to do?
Load typekit asynchronously using jQuery using CoffeeScript
$ ->
class Brianflove
@_initialized = null
constructor: () ->
if @_initialized is not null
throw "Do not instantiate this class on your own"
@_initialized = true
initTypeKit: () ->
config =
kitId: 'your-id-goes-here'
scriptTimeout: 3000
active: ->
$('.container h1, .container .lead').each ->
$(@).fadeIn 800
$('html').addClass 'wf-loading'
t = setTimeout ->
$('html').removeClass 'wf-loading'
$('html').addClass 'wf-inactive'
, config.scriptTimeout
url: '//' + config.kitId + '.js'
dataType: 'script',
cache: true,
success: ->
clearTimeout t
Typekit.load config
brianflove = new Brianflove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment