Bug Tracker

Modify

Ticket #4196 (closed bug: duplicate)

Opened 5 years ago

Last modified 4 years ago

$(fn) acts differently in browsers if jQuery loaded late

Reported by: friedcell Owned by: brandon
Priority: major Milestone: 1.3.2
Component: event Version: 1.3.1
Keywords: Cc:
Blocking: Blocked by:

Description

If you load jQuery after DOMContentLoaded and load events fired modern browsers will never fire $(fn) while IE will fire it immediately since it doesn't rely on events.

Looking at the code a simple check should be made after setting readyBound: if (document.readyState === 'complete')

return jQuery.ready();

Attachments

test.html Download (950 bytes) - added by fidlej 4 years ago.
A test to reproduce the bug.

Change History

Changed 4 years ago by fidlej

A test to reproduce the bug.

comment:1 Changed 4 years ago by fidlej

The function passed to $(document).ready() is never called if:

  1. 1) Using Firefox 3.5 or older.
  2. 2) And loading jquery on demand. I.e., by inserting jquery script into <head> dynamically.

How to reproduce:

  1. 1) Open the attached test.html.
  2. 2) Click on the "Load jQuery" link.
  3. 3) Two alerts should arise.

Only the "before ready" alert arises on Firefox 3.5. The "inside ready" alert is never seen there.

The old Firefox don't have document.readyState.

comment:2 Changed 4 years ago by SlexAxton

  • Status changed from new to closed
  • Resolution set to duplicate

comment:3 Changed 4 years ago by SlexAxton

Duplicate of #4889.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.