YUI: ensuring DOM elements and scripts are ready

Posted by dound on Stack Overflow See other posts from Stack Overflow or by dound
Published on 2010-05-07T03:57:45Z Indexed on 2010/05/07 3:58 UTC
Read the original article Hit count: 467

Filed under:
|
|
  1. If I put my inline script after the DOM elements it interacts with, should I still use YUI 3's domready event?
    I haven't noticed any problems, and it seems like I can count on the browser loading the page sequentially. (I already use YUI().use('node', ... to make sure the YUI functions I need have been loaded since the YUI script is a separate file.)

  2. Is there a way to speed up the loading of widgets like YUI 2's calendar?
    I load the appropriate script in <head> element of my page. I use YUI().use('yui2-calendar', ... to make sure the Calendar widget is available. Unfortunately, this causes a short but noticeable delay when I load my page with the calendar. If I omit the YUI().use('yui2-calendar', ... code then it shows up without a noticeable delay - but I guess this could cause the Calendar to not show up at all if the YUI script doesn't load in time?

  3. With regards to #2, is it possible to reduce the visual artifact of the calendar not being present and then showing up?
    I've made it slightly better by specifying a height and width for the parent div so that at least the space is already allocated => minimal shifting around when it does load.

© Stack Overflow or respective owner

Related posts about yui

Related posts about JavaScript