Ticket #7374 (closed bug: fixed)
(Google Chrome) ready Event is fired twice on back button.
| Reported by: | cyberheroo@… | Owned by: | cyberheroo@… |
|---|---|---|---|
| Priority: | high | Milestone: | 1.4.4 |
| Component: | core | Version: | 1.4.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
On Google Chrome(version 7.0.517.41 and possible others) the ready event is fired when user views the page a second time by clicking the back button, but DOM modifications are kept from the previous view. So, DOM modifications in the $(document).ready(...) are made twice. Event handlers are only attached once! IIRC Google integrated a feature that caches the DOM when clicking a link to make sure that it's available immediate on back button click.
Change History
comment:1 Changed 3 years ago by rwaldron
- Owner set to cyberheroo@…
- Status changed from new to pending
- Component changed from unfiled to core
- Milestone 1.5 deleted
comment:2 Changed 3 years ago by etienne@…
confirm on chromium 7.0.517.44 with jquery 1.4.3 and -git
test case (I didn't find how to use jsFiddle for this): http://dansard.localhostz.org/~etienne/log/chrome-jquery-readylist-twice.html
note: the bug is present here without the back button trick. In local, I have to follow the link then press back (same on a production server).
On first load: DOMContentLoaded is fired, jQuery.ready() callback is called, readyList functions are called, readyList is cleared, load event is fired
On back button/on my self hosted server: DOMContentLoaded is fired, readyList functions are called, the load event is fired, readyList functions are recalled, readyList is cleared (by the load callback), DOMContentLoaded callback crash with "Uncaught TypeError: Cannot read property '2' of null" error
thanks.
comment:3 Changed 3 years ago by Ben Lambert <ben.nagoya@…>
This issue renders jQuery UNUSABLE in Chrome. This should be marked as a high priority issue.
comment:4 Changed 3 years ago by anonymous
This issue was fixed in https://github.com/jquery/jquery/commit/983548f8ebc3fcd1bb4600bc4b740cb8a5d4c48b and made it into the new 1.4.4 release.
This ticket also appears to be more or less a duplicate of #7352 (different triggers, same problem).
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!