PDA

View Full Version : yui ext document page "loading" message



sjivan
22 Nov 2006, 12:18 PM
I noticed that in the source of the yui ext docs, the yui scripts are included in the body of the html page (and not in the head section) after a "Loading" div is displayed.

Typically external scripts are included in the head section and I was curious why this page had them in the body section. What are the differences? Do the scripts get cached if they are included in the body section?


Thanks,
Sanjiv

jbowman
22 Nov 2006, 12:55 PM
I think it was more so there would be the loading indicator while the other scripts were downloaded and run by the client.

jack.slocum
22 Nov 2006, 1:01 PM
Exactly. If they are in the head then they will be downloaded before the loading message is displayed. By including them after the loading indicator, they are downloaded after the message is visible.

sjivan
22 Nov 2006, 1:01 PM
yes, I realize that but my question was whether there are they drawbacks to this (like no caching) as I havent seen many other sites using this approach. And if there arent any real drawbacks, i'm surprised why more sites dont use this as the effect is pretty neat.

Thanks,
Sanjiv

jack.slocum
22 Nov 2006, 1:02 PM
No, it still works the same as far as I have experienced.

brian.moeskau
22 Nov 2006, 1:07 PM
Shouldn't affect caching either way. The browser just stores the url to the css file/js file/image/etc. and matches new resource requests against it's cached url list to know whether to serve a local copy. It doesn't know or care which particular section of the html the url originated from. Think of all the stuff that gets cached that's usually not in the HEAD (images, flash, etc.).

sjivan
22 Nov 2006, 1:08 PM
ok, thanks all. I also confirmed via Fiddler the scripts are indeed cached.

allaboutyui
22 Nov 2006, 3:16 PM
Presumably this optimises loading times considerably, especially if you display some static content which doesn't require the scripts initially.