Ajax and Large Images
November 17th, 2007Finally got impacted by a bug that was a large discussion topic on the Dojo forum, funny enough when the bug reared it’s ugly head I didn’t even think of the Gecko bug, as I’d assumed it was fixed in Dojo, weirdly enough it actually is fixed, it’s just not fixed by default.
The issue arises if you try and do Dojo package loading or any Ajax calls using any of the Dom Loaded techniques to load them before the page has finished loading all of it’s content AND there are images that add up to more than 65k, Gecko will freeze. I say Gecko, because this is not a firefox bug, it’s occurs on all platforms, in every browser using Gecko; Camino, Firefox, etc.
Dojo these days uses an “onDomLoaded” style of event to trigger the loading of sub packages, or widgets. If you are using dojo.require or have templates html or css in a widget it will be using AJAX to load those files into the browser window.
So if you have a dojo require in your head ann image that is bigger than 65k, expect your Gecko powered browser to fall flat on it’s face in an almost anonymous application crash that seems to occur for no apparent reason.
It’s an acknowledged Gecko Bug, but one that won’t get fixed until it makes an appearance in Firefox 3.0. So it’s still an issue, and one that if you come across it, you might spend a while chasing your tails before the solution becomes apparent.
What’s awesome is that the solution if you’re using Dojo is crazy simple, yet not very well documented (not in a way that I could easily find).
All you need is to set a variable in djconfig and Dojo won’t use ondomloaded to do the Ajax loading, it’ll wait for the ‘official’ onload for the window, and thus won’t be trying to do Ajax loading while the image tries to load, as the image is loaded.
So after digging around, here is the list of djconfig variables you can set:
-
-
var config = {
-
isDebug: false,
-
allowQueryConfig: false,
-
baseScriptUri: "",
-
baseRelativePath: "",
-
libraryScriptUri: "",
-
iePreventClobber: false,
-
ieClobberMinimal: true,
-
preventBackButtonFix: true,
-
delayMozLoadingFix: false,
-
searchIds: [],
-
parseWidgets: true
-
};
-
The one of mention is the obviously named “delayMozLoadingFix”.
So if you make your djconfig into:
-
-
<script type="text/javascript">
-
var djConfig = {
-
delayMozLoadingFix: true
-
};
-
</script>
-
This will delay the load and prevent the firefox load crash if you have images/flash movies bigger than 65k in the page.

November 21st, 2007 at 2:36 pm
Oh and forgot to mention that “delayMozLoadingFix: true” applies to Dojo 1.0 as well, as it’s not a dojo bug, but more a browser bug, this setting is still available for Dojo in the current release.