Ticket #2528334 (closed enhancement)

Reporter


Luke Smith
Opened: 10/16/09
Last modified: 08/1/12
Status: closed
Type: enhancement
Resolution: fixed

Owner


Dav Glass
Target Release: 3.6.0
Priority: P3 (normal)
Summary: YUI configuration to delay use() callback until domready or window load
Description:

Depending on where implementers put the YUI instantiation code, there will be a race between the async module loading and the DOM tree assembly status. In YUI 2, it was typical to use
YAHOO.util.Event.onDOMReady(...). In YUI 3, the domready might occur before or after the used modules are loaded and applied to the Y instance.

It appears the only way to ensure safe DOM manipulation would be to either put the instantiation code at the bottom of the body or wrap a decent chunk of the use() callback in a Y.on('domready', ... )
subscription.

It would be convenient to have this eventuality handled by a constructor config, e.g. delayUntil: 'domready' or 'window.load', whereby the use callback would be wrapped in the appropriate event
subscription under the hood.

I can also imagine something like delayUntil: '#container.contentready', but the selector syntax vs the target and event identification would be messy (and require Selector).

Type: enhancement Observed in Version: 3.0.0
Component: YUI Global Object Severity: S3 (normal)
Assigned To: Dav Glass Target Release: 3.6.0
Location: Library Code Priority: P3 (normal)
Tags: Relates To:
Browsers: N/A
URL:
Test Information:

Change History

Adam Moore

YUI Contributor

Posted: 10/16/09
  • milestone changed to FUTURE
  • status changed from new to accepted

There is actually another feature request for this somewhere, but it doesn't include the window load event option. It is important to note that use() consumers can use either one of the events and be assured that they will fire regardless of whether or not they have already happened (given the normal use case where YUI was included on the page inline).

George

YUI Developer

Posted: 04/20/11

Dav Glass

Posted: 04/26/11
  • status changed from assigned to accepted

Dav Glass

Posted: 03/30/12

Ticket #2528133 was marked as a duplicate of this ticket.

Dav Glass

Posted: 04/5/12
  • milestone changed from FUTURE to 3.6.0

Dav Glass

Posted: 04/5/12
  • estimated changed from 0 to 0.5
  • remaining changed from 0 to 0.5

Dav Glass

Posted: 05/11/12
  • sprint changed to sprint 2

Dav Glass

Posted: 05/15/12
  • completed changed from 0 to 0.5
  • remaining changed from 0.5 to 0

Dav Glass

Posted: 05/15/12
  • resolution changed to fixed
  • status changed from accepted to checkedin

Fixes #2528334 - Added delayUntil config option

You can now delay the use callback until
domready, load, contentready or available
events have been fired.
View Commit: 7b6fa6b4ef3b58e15b90b71090d511180d8f8d4e

Jenny Donnelly

YUI Developer

Posted: 08/1/12
  • status changed from checkedin to closed

Shipped in 3.6.0. Marking closed/fixed.