I am creating a site that uses Cufon and is especially heavy in terms of page weight due to the large amount of Javascript. Therefore, I am trying to load the script asynchronously with head.js ( http://headjs.com/ ) as follows:
head.js("http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js", function() { head.js("/js/libs/cufon-yui.js", function() { head.js("/js/shared/Stag_Bold_700.font.js" , function() { Cufon.replace('h1', { fontFamily: 'Stag Bold' }); }); }); });
So, jQuery is loaded first, the subsequent cufon lib file and cufon font are loaded sequentially, and then Cufon is finally called to replace H1. Obviously, this is a shorthand example with fewer replacements, but it still doesn't work when you are just trying to replace H1.
The problem is that ONLY in Internet Explorer (6/7/8) the text is not replaced, but I see that Cufon has definitely been called. I can verify this because the class "cufon-active cufon-ready" has been added to the tag. When I check the markup using the IE Developer toolbar, the cufon / cufoncanvas tags are inside the selected elements, but, if they donβt want a better word, they are invisible.
In IE9, the script behaves as intended, similarly to Chrome and Firefox. I tried to customize the Cufon drawing engine and updated to the latest version 1.09i for a good grade. If I move the Cufon operator to the caller in the document ready event instead of loading asynchronously, it works, but I'm trying to optimize the page loading, and my site will use a number of Cufon fonts, as well as many other JS plug-ins. I also tried using both labs.js and head.js to asynchronously load the corresponding files.
giles
source share