Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@padde
Created September 14, 2011 15:43
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save padde/1216920 to your computer and use it in GitHub Desktop.
Save padde/1216920 to your computer and use it in GitHub Desktop.
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
Copy link

cassler commented Jan 19, 2012

elegant.

@orafaelfragoso
Copy link

Where do I add that?

@octosteve
Copy link

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
Copy link

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