Bug Tracker

Opened 9 years ago

Closed 9 years ago

#13655 closed feature (fixed)

Create unit test for window.load .ready() fallback

Reported by: m_gol Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0b2
Keywords: Cc:
Blocked by: Blocking:


I was wondering, is a fallback from document DOMContentLoaded to window load in jQuery.ready.promise still needed in jQuery 2.x? (line 789 in src/core.js on master). IE supports it from 9 but other browsers have had support for much longer time; it's also supported on old Android (at least 2.3).

This would save a few bytes if it's not needed any more.

Change History (8)

comment:1 Changed 9 years ago by Rick Waldron

Give it a shot

comment:2 Changed 9 years ago by m_gol


I've run the full test suite in current Chrome, Firefox & Safari as well as in IE9 & IE10 and all went fine (though, obviously, any bugs here might not be catched in a usual test).

I don't have any Android devices to test, though.

comment:3 Changed 9 years ago by dcherman

Is it possible for jQuery to be loading after DOMContentLoaded, but before the load event has occurred ( think RequireJS or some other script loader )?

If that's the case, then jQuery.ready would never be fired since document.readyState would be "interactive" at that point.

Version 0, edited 9 years ago by dcherman (next)

comment:4 Changed 9 years ago by mikesherov

window.load is needed for the reason dcherman describes. A long loading iframe on a page could keep the page "interactive" if jQuery is async loaded after DomContentLoaded. Rather than remove the fallback maybe write a test proving its necessity?

comment:5 Changed 9 years ago by m_gol

OK, I'll try to write a test case.

comment:6 Changed 9 years ago by m_gol

I updated my pull request, reverting the removal and adding a test, see there for further comments & remarks:

comment:7 Changed 9 years ago by dmethvin

Status: newopen
Summary: Remove DOMContentLoaded fallback to window load?Create unit test for window.load .ready() fallback

Marking as open and renaming to reflect the end result since we're not removing the fallback.

comment:8 Changed 9 years ago by Michał Gołębiowski

Resolution: fixed
Status: openclosed

Fix #13655. Add test for jQuery.ready.promise fallback load. Close gh-1209.

Changeset: 32b066d3805a48f8c8312562ed52a1b5910b1d85

Note: See TracTickets for help on using tickets.