Fire event after typekit load
Typical typekit library and function call:
<script type="text/javascript" src="//use.typekit.net/xxx.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
Convert it into this
<script type="text/javascript" src="//use.typekit.net/xxx.js"></script>
<script type="text/javascript">try{Typekit.load({active:function(){main()}});}catch(e){}</script>
This will call the main function after it successfully loads typekit. Create you function main.
function main() {
alert("Loaded After Typekit!");
}
Written by jay mabazza
Related protips
1 Response
This is very helpful for TypeKit fonts.
Google and TypeKit worked together to develop the "Web Font Loader" which works in a similar way and supports both Typekit and Google Web Fonts (amongst others).
Here's the GitHub repo: https://github.com/typekit/webfontloader
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#