JavaScript includes and DOMContentLoaded event

My article about the non-blocking behavior of javascript includes was recently published on the YUI blog. Luke Chambers asked how does this method affect DOMContentLoaded event, so I gave it a shot.

The test examples are:

Basically, I added an event listener to document DOMContentLoaded event and to the onload events of every script, image and the document. I also exaggerated the loading time of scripts and images.

Results

Normal script tag

js: Sat Jul 26 2008 15:53:33 GMT-0700 (Pacific Daylight Time)
DOMContentLoaded: Sat Jul 26 2008 15:53:33 GMT-0700 (Pacific Daylight Time)
img2: Sat Jul 26 2008 15:53:37 GMT-0700 (Pacific Daylight Time)
img1: Sat Jul 26 2008 15:53:37 GMT-0700 (Pacific Daylight Time)
img6: Sat Jul 26 2008 15:53:37 GMT-0700 (Pacific Daylight Time)
img3: Sat Jul 26 2008 15:53:37 GMT-0700 (Pacific Daylight Time)
img5: Sat Jul 26 2008 15:53:37 GMT-0700 (Pacific Daylight Time)
img4: Sat Jul 26 2008 15:53:37 GMT-0700 (Pacific Daylight Time)
img8: Sat Jul 26 2008 15:53:40 GMT-0700 (Pacific Daylight Time)
img7: Sat Jul 26 2008 15:53:40 GMT-0700 (Pacific Daylight Time)
onload: Sat Jul 26 2008 15:53:40 GMT-0700 (Pacific Daylight Time)

DOM-included script

DOMContentLoaded: Sat Jul 26 2008 15:55:29 GMT-0700 (Pacific Daylight Time)
img1: Sat Jul 26 2008 15:55:32 GMT-0700 (Pacific Daylight Time)
img2: Sat Jul 26 2008 15:55:32 GMT-0700 (Pacific Daylight Time)
img6: Sat Jul 26 2008 15:55:32 GMT-0700 (Pacific Daylight Time)
img4: Sat Jul 26 2008 15:55:32 GMT-0700 (Pacific Daylight Time)
img3: Sat Jul 26 2008 15:55:32 GMT-0700 (Pacific Daylight Time)
img5: Sat Jul 26 2008 15:55:32 GMT-0700 (Pacific Daylight Time)
img8: Sat Jul 26 2008 15:55:35 GMT-0700 (Pacific Daylight Time)
img7: Sat Jul 26 2008 15:55:35 GMT-0700 (Pacific Daylight Time)
script: Sat Jul 26 2008 15:55:39 GMT-0700 (Pacific Daylight Time)
onload: Sat Jul 26 2008 15:55:39 GMT-0700 (Pacific Daylight Time)

In any event, the document onload waits for the script, no matter how it's included.

Tags: , ,

One Response to “JavaScript includes and DOMContentLoaded event”

  1. lswphvbfc Says:

    [url=http://vcptv.com/wp-content/plugins/wplite/mulberryhandbagsuk.php]Mulberry Bags Outlet[/url]Eyelash curler is just another tool employed in the interest of beauty . After all, “beauty is pain”! From eyeliner to lip gloss, there is no feature of your face that cannot be heightened by some form of make-up or beauty procedure. Some beauty tools, nevertheless, can be scary and daunting – like that odd-looking contraption that they like to call an eyelash curler.

    Zhou Pangang just relieved, academics Li Hua Road: But Xing Marshal’s meaning. Leave Zhongtiaoshan, his troops go Zhongyuan. LIU Liu Liu also Yang Hu they were officers and soldiers everywhere getting pounded like a lost dog in the Central Plains. Hey … Sighed shook his head Soga finally understand the reason why cost a lot of money on the force but fat will not win over the people or say we refused allegiance with his force and do not want to use. Can not be used after all …[url=http://www.workconsulting.com/wp-content/plugins/wplite/cheapmulberry.php]Cheap Mulberry[/url]Filmed above the company’s staff is unable to stop the enthusiastic fans. Zhang Shaoyu appeared Yuelushan very excited to make a lot of visitors have filming around a packed coming here. Many enthusiastic fans willing to put their lives at risk in order to get close to the idol look 向那 wall by Jacky dissemination of company security department security personnel consisting of wall from the impact..

    Yes. Lin Rong nodded, sighed: Since a lot of things destined to do, I will not put off this morning, I helped his wife at home to deal with some Shoji, etc. After noon, I went to see Lee Tae seek a job. The entire production was done with only a “keyboard and only four chairs”. There’s no special effects, no stunts, no huge choruses. There is only the brilliant music, lyrics, and performers.[url=http://lapopottedannecharlotte.com/wp-content/plugins/wp-slimstat/mulberrymenbag.php]Mulberry Women Bag[/url]Many people buy the jewelry at local stores or online. It is best to buy them from online stores because of the large selection. Shoppers can find one of a kind or exotic jewelry pieces. In fairness, the world says a lot of nice things people and land, and it can be said quite. The stability of the world , and the maintenance of the royal family are shit. But not the war, people’s lives better, these touches come from the northeast all the way to look in the eyes..

    However, more beautiful than they, naturally high exhibition, did not spend a little effort, a little effort did not pay. Put land shadow dress size again expanded tenfold, Tian stores. Downtown area all open in the city’s commercial center, and is an independent real estate, count the holidays, a daily average of each store can sell nearly 100 sets of clothing, all the stores together, day sold nearly ten thousand a year about like a million pieces, and Hualong garment factory production is almost exactly the same..Top of pageAbstractCharacterization and distribution of interstitial cell types in the renal cortex of rats. A precise classification of the cellular components of the cortical peritubular interstitium is missing in spite of its physiological and pathophysiological importance. By combining electronmicroscopy and immunohistochemistry we attempted to better identify and localize the different interstitial cell types in rat kidney, with special attention to the cortex.

    When you shop for items in a store, you can use your five senses to assess quality. Online, however, it can be trickier (how are you supposed to know if the items you’re checking out are legit?). And with the recent explosion in online consignment stores, we wanted to arm you with a few tips that’ll help you get the most from your WWW clothing-buying experience..

    [url=http://takalog.com/wp-content/redbottomheels.php/]Red Bottom Heels[/url]
    [url=http://www.x-tec.de/typo3conf/ext/rgtabs/pi1/cheapghds.php]GHDs UK[/url]
    [url=http://savewaterteam.com/wg/cheapghd.php]GHDs UK Outlet[/url]
    [url=http://takalog.com/wp-content/cheapmulberryuk.php/]Cheap Mulberry UK[/url]
    [url=http://bugyiu.com/thenorthface.php/]North Face Wholesale[/url]

Leave a Reply