Execute a function when a <link> element has finished loading

Posted by nornagon on Stack Overflow See other posts from Stack Overflow or by nornagon
Published on 2010-05-23T01:21:11Z Indexed on 2010/05/23 2:41 UTC
Read the original article Hit count: 484

Filed under:
|

I'm using jQuery Masonry to lay out my page, but I'm using a custom @font-face font. The problem being that Masonry doesn't know the metrics of the font until it's loaded.

The Masonry docs suggest that you use $(window).load() instead of $(document).ready() to call the layout functions, but I don't want to have to wait until all the images etc. load. I can specify the dimensions of the images exactly, so Masonry doesn't need to wait until they're loaded. It's just the text that's the problem.

How can I get jQuery to call a callback when the <link> element that links in the font finishes loading?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery