Skip to content

Instantly share code, notes, and snippets.

@padde

padde/gist:1216920

Created Sep 14, 2011
Embed
What would you like to do?
Rails Helper for Typekit integration
def typekit_include_tag apikey
javascript_include_tag("http://use.typekit.com/#{apikey}.js") +
javascript_tag("try{Typekit.load()}catch(e){}")
end
@cassler

This comment has been minimized.

Copy link

@cassler cassler commented Jan 19, 2012

elegant.

@orafaelfragoso

This comment has been minimized.

Copy link

@orafaelfragoso orafaelfragoso commented May 15, 2013

Where do I add that?

@octosteve

This comment has been minimized.

Copy link

@octosteve octosteve commented Oct 30, 2013

Add this in your application helper.

Get rid of the http: to support both http and https automatically.

def typekit_include_tag apikey
  javascript_include_tag("//use.typekit.com/#{apikey}.js") +
  javascript_tag("try{Typekit.load()}catch(e){}")
end
@transat

This comment has been minimized.

Copy link

@transat transat commented Jan 20, 2014

Cool. How would you add 'async' to that? As recommended here: http://www.hagenburger.net/BLOG/A-Better-Typekit-Integration.html

Like so?

def typekit_include_tag(apikey)
    javascript_include_tag("//use.typekit.com/#{apikey}.js", :async => true) +
    javascript_tag("try{Typekit.load()}catch(e){}")
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment