Last Updated: February 25, 2016
·
1.297K
· jaymabazza

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!");
}

1 Response
Add your 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 ·