Created
September 14, 2011 15:43
-
-
Save padde/1216920 to your computer and use it in GitHub Desktop.
Rails Helper for Typekit integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def typekit_include_tag apikey | |
javascript_include_tag("http://use.typekit.com/#{apikey}.js") + | |
javascript_tag("try{Typekit.load()}catch(e){}") | |
end |
Where do I add that?
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
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
elegant.