<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>InfoSauce: Cross-browser onDOMContentLoaded</title>
  <id>tag:blog.infosauce.com,2005:Typo</id>
  <generator uri="http://www.typosphere.org" version="4.0">Typo</generator>
  <link href="http://blog.infosauce.com/xml/atom/article/11/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.infosauce.com/articles/2005/09/24/cross-browser-ondomcontentloaded" rel="alternate" type="text/html"/>
  <updated>2006-10-26T21:43:54-07:00</updated>
  <entry>
    <author>
      <name>Tim</name>
    </author>
    <id>urn:uuid:dacf94ae-5012-42e9-a8aa-00f5fa2c1fcb</id>
    <published>2005-09-24T16:08:00-07:00</published>
    <updated>2006-10-26T21:43:54-07:00</updated>
    <title type="html">Cross-browser onDOMContentLoaded</title>
    <link href="http://blog.infosauce.com/articles/2005/09/24/cross-browser-ondomcontentloaded" rel="alternate" type="text/html"/>
    <category term="css-dom-standards" scheme="http://blog.infosauce.com/articles/category/css-dom-standards" label="CSS-DOM-standards"/>
    <summary type="html">&lt;p&gt;&lt;a href="http://dean.edwards.name/weblog/2005/09/busted/"&gt;An elegant solution to the window.onload problem in Mozilla and IE.&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Client-side developers have long been frustrated by the shortcomings of window.onload, namely that it takes too long before firing if you want to attach scripts to rework the &lt;span class="caps"&gt;&lt;span class="caps"&gt;DOM&lt;/span&gt;&lt;/span&gt;, yet you have to wait before the &lt;span class="caps"&gt;&lt;span class="caps"&gt;DOM&lt;/span&gt;&lt;/span&gt; is parsed before manipulating it.&lt;/p&gt;

    &lt;p&gt;The &lt;a href="http://greasemonkey.mozdev.org/"&gt;Greasemonkey&lt;/a&gt; chaps solved the problem in Mozilla Firefox by uncovering the proprietary &lt;span class="caps"&gt;&lt;span class="caps"&gt;DOM&lt;/span&gt;&lt;/span&gt;ContentLoaded event.  Now not solving the problem in all browsers would be acceptable, since the other browsers could fall-back to the late firing window.onload, but it’s unrealistic to consider a solution for general web use that doesn’t at least take care of 90% of the market (Windows IE).&lt;/p&gt;

    &lt;p&gt;Ever since the &lt;a href="http://www.quirksmode.org/"&gt;&lt;span class="caps"&gt;PPK&lt;/span&gt;&lt;/a&gt; mentioned something in his blog about a way to solve it in IE and Mozilla(maybe Safari) in the &lt;a href="http://www.quirksmode.org/blog/archives/2005/06/you_shouldve_be_1.html"&gt;@media event entries&lt;/a&gt; a number of us have been very excited.  We’ve been &lt;a href="http://dean.edwards.name/weblog/2005/02/order-of-events/#comment2370"&gt;contemplating the best way to use this knowledge&lt;/a&gt;  involving complicated schemes requiring behaviors in &lt;span class="caps"&gt;IE &lt;/span&gt;(.htc files) and waiting for the mysterious “more details to come”&lt;/p&gt;

    &lt;p&gt;Well, the details have arrived, and it seems to make most of the scripts to handle an early firing domloaded event moot. Dean Edwards has delivered an &lt;a href="http://dean.edwards.name/weblog/2005/09/busted/"&gt;elegant solution to the window.onload problem in Mozilla and IE.&lt;/a&gt; If Safari/kthml, Opera, or any of the other browsers not covered by this are an important enough factor at your site, you might have to still think about an alternative like &lt;a href="http://www.brothercake.com/site/resources/scripts/domready/"&gt;brothercake’s domFunction.&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;We’re going to just stick with Dean Edwards solution for now and call it good, though.  Especially since, according to work done on the sIFR image replacement technique, &lt;a href="http://web-graphics.com/mtarchive/001635.php"&gt;Safari won’t layout the page properly until the images are loaded&lt;/a&gt; (read the 3rd comment).  This means having Safari wait for the window.onload is actually a feature.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://dean.edwards.name/weblog/2005/09/busted/"&gt;An elegant solution to the window.onload problem in Mozilla and IE.&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Client-side developers have long been frustrated by the shortcomings of window.onload, namely that it takes too long before firing if you want to attach scripts to rework the &lt;span class="caps"&gt;&lt;span class="caps"&gt;DOM&lt;/span&gt;&lt;/span&gt;, yet you have to wait before the &lt;span class="caps"&gt;&lt;span class="caps"&gt;DOM&lt;/span&gt;&lt;/span&gt; is parsed before manipulating it.&lt;/p&gt;

    &lt;p&gt;The &lt;a href="http://greasemonkey.mozdev.org/"&gt;Greasemonkey&lt;/a&gt; chaps solved the problem in Mozilla Firefox by uncovering the proprietary &lt;span class="caps"&gt;&lt;span class="caps"&gt;DOM&lt;/span&gt;&lt;/span&gt;ContentLoaded event.  Now not solving the problem in all browsers would be acceptable, since the other browsers could fall-back to the late firing window.onload, but it’s unrealistic to consider a solution for general web use that doesn’t at least take care of 90% of the market (Windows IE).&lt;/p&gt;

    &lt;p&gt;Ever since the &lt;a href="http://www.quirksmode.org/"&gt;&lt;span class="caps"&gt;PPK&lt;/span&gt;&lt;/a&gt; mentioned something in his blog about a way to solve it in IE and Mozilla(maybe Safari) in the &lt;a href="http://www.quirksmode.org/blog/archives/2005/06/you_shouldve_be_1.html"&gt;@media event entries&lt;/a&gt; a number of us have been very excited.  We’ve been &lt;a href="http://dean.edwards.name/weblog/2005/02/order-of-events/#comment2370"&gt;contemplating the best way to use this knowledge&lt;/a&gt;  involving complicated schemes requiring behaviors in &lt;span class="caps"&gt;IE &lt;/span&gt;(.htc files) and waiting for the mysterious “more details to come”&lt;/p&gt;

    &lt;p&gt;Well, the details have arrived, and it seems to make most of the scripts to handle an early firing domloaded event moot. Dean Edwards has delivered an &lt;a href="http://dean.edwards.name/weblog/2005/09/busted/"&gt;elegant solution to the window.onload problem in Mozilla and IE.&lt;/a&gt; If Safari/kthml, Opera, or any of the other browsers not covered by this are an important enough factor at your site, you might have to still think about an alternative like &lt;a href="http://www.brothercake.com/site/resources/scripts/domready/"&gt;brothercake’s domFunction.&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;We’re going to just stick with Dean Edwards solution for now and call it good, though.  Especially since, according to work done on the sIFR image replacement technique, &lt;a href="http://web-graphics.com/mtarchive/001635.php"&gt;Safari won’t layout the page properly until the images are loaded&lt;/a&gt; (read the 3rd comment).  This means having Safari wait for the window.onload is actually a feature.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>Tim Connor</name>
    </author>
    <id>urn:uuid:aa449f06-0ba6-450b-85ee-5a41d3171de2</id>
    <published>2005-09-25T16:08:00-07:00</published>
    <updated>2006-10-22T21:34:44-07:00</updated>
    <title type="html">Comment on Cross-browser onDOMContentLoaded by Tim Connor</title>
    <link href="http://blog.infosauce.com/articles/2005/09/24/cross-browser-ondomcontentloaded#comment-12" rel="alternate" type="text/html"/>
    <content type="html">&lt;p&gt;He also added a method to handle IE the &lt;a href="http://dean.edwards.name/weblog/2005/09/busted2/" rel="nofollow"&gt;other way that has been discussed, using an HTC and ondocumentready,&lt;/a&gt; in case anyone has any problems with the “defer”  approach.&lt;/p&gt;</content>
  </entry>
</feed>
