Bug Tracker

Opened 12 years ago

Closed 12 years ago

#9389 closed enhancement (wontfix)

Make holdReady() Work After DOM Ready

Reported by: johncrenshaw@… Owned by:
Priority: low Milestone: None
Component: event Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by dmethvin)

Allow holdReady() to work AFTER the document has loaded.

This is a big deal when using script loaders + AJAX content. It turns out that the change is also trivial: just 5 lines all in one place. My 1.6 pull request ( https://github.com/jquery/jquery/pull/371 ) includes the whole change (just a few lines long) and the discussion on the pull request includes a good explanation of how and why this is useful ( https://github.com/jquery/jquery/pull/371#issuecomment-1104081 ).

the cliff notes version is that a good script loader is an ideal way to resolve some of the nasty issues surrounding AJAX, widgets, and code architecture on both the client and server side. HOWEVER, for this to work, the ready event needs to be able to be deferred after the AJAX response: otherwise all we have is an over-architected way of putting stuff in the header during the page load process.

The edit DOES change one documented behavior: currently the documentation says that holdReady() does nothing after the document has loaded. This is likely a pretty useless behavior, since any call to holdReady still OUGHT to be reciprocal, and the logical expectation in the code is normally that functions passed to $(document).ready() will not fire when there is a hold. Bottom line, it is highly improbable that this change will break anything that anyone is depending on.

Change History (11)

comment:1 Changed 12 years ago by Timmy Willison

Component: unfiledevent
Keywords: needsreview added
Priority: undecidedlow
Status: newopen

+1 As a script loader user, I would like this.

comment:2 Changed 12 years ago by john

Type: bugenhancement

Confirmed in triage.

comment:3 Changed 12 years ago by dmethvin


I'll leave the ticket open for discussion during 1.8 feature voting; the closed PR has very good discussion pro and con.

comment:4 Changed 12 years ago by dmethvin

Keywords: 1.8-discuss added; needsreview removed

comment:5 Changed 12 years ago by dmethvin

-1, Script loaders should have their own conventions for this; redefining ready semantics just seems wrong.

comment:6 Changed 12 years ago by mikesherov

Description: modified (diff)


comment:7 Changed 12 years ago by Rick Waldron

Description: modified (diff)

-1, Feature creep precedent

comment:8 Changed 12 years ago by jaubourg

Description: modified (diff)

-1, You need another event for this. I won't repeat what I said in the pull request's comments.

comment:9 Changed 12 years ago by Timmy Willison


comment:10 Changed 12 years ago by hkdobrev@…

-1 IMHO scripts loaders and module loader should be used outside of jQuery. Not even in jQuery plugins. You should look at all of you javascript code as some kind of modules (even one big module), including jQuery.

The best practice is to load jQuery and other scripts on the bottom of the page and additional script loaders in the head (if some of the modules should be loaded based on some conditions even before loading and are crucial in the beginning) or if you don't have modules that needs to be loaded at the beginning you can use the loader in the bottom of the body as well.

comment:11 Changed 12 years ago by dmethvin

Description: modified (diff)
Keywords: 1.8-discuss removed
Milestone: 1.nextNone
Resolution: wontfix
Status: openclosed
Note: See TracTickets for help on using tickets.