jQuery.readyException(error) (since 3.1) is the hook jQuery calls when a function wrapped in jQuery() / $(document).ready() throws synchronously. By default it re-throws inside setTimeout so the error reaches the console and window.onerror instead of being swallowed.
Remember
// Default behavior (conceptually):
jQuery.readyException = function (error) {
window.setTimeout(function () {
throw error;
});
};
// Official override example:
jQuery.readyException = function (error) {
console.error(error);
};
// Triggered by:
$(function () {
throw new Error("Ready handler failed");
});
#log stays on the "Ready ran…" message
readyException does NOT receive the async error
Use try/catch, promise .catch, or window.onerror instead
How It Works
Ready succeeds. The callback itself does not throw.
Later.setTimeout throws on a future turn.
Miss. That throw is outside jQuery’s ready try/catch.
Handle elsewhere. Use local catch, promise handlers, or window.onerror.
Edge Cases & Pitfalls
Check these before relying on readyException in production.
sync
Only synchronous throws
Timers, promises, and later event handlers never call this hook.
override
Replacing the default hides console noise
If you only console.error and never rethrow, there is no uncaught exception for window.onerror.
version
Needs jQuery 3.1+
Older builds do not expose jQuery.readyException — check your version first.
order
Assign the hook before ready runs
If ready already fired and threw, a late override cannot catch that past error.
Compatibility
Browser Support
jQuery.readyException has been part of jQuery since 3.1. It works wherever your loaded jQuery 3.1+ build runs.
✓ Stable · jQuery 3.1+
jQuery.readyException()
Available in modern jQuery 3.x builds. Prefer a current 3.7+ release. Not present on jQuery 1.x / 2.x.
100%jQuery 3.1+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
readyExceptionjQuery 3.1+
Bottom line: Safe on jQuery 3.1+. Override early, keep sync-only expectations clear, and rethrow when you still want console visibility.
Analysis
Performance Notes
Approach
Cost
Best for
Default async rethrow
Cheap
Keeping bugs visible
Light custom log / UI
Cheap
Demos and local diagnostics
Heavy work inside the hook
Expensive
Avoid — report briefly, then continue
The hook runs only when a ready callback fails. Keep it tiny: log, enqueue a report, optionally rethrow — do not rebuild the page there.
Remember
Key Takeaways
Role: catches sync throws from $(fn) / .ready().
Default: rethrows in setTimeout so errors stay visible.
Override:jQuery.readyException = function (error) { … }.
Limit: async failures need other tools — not this hook.
One line:jQuery.readyException is the 3.1+ hook for sync ready failures — customize logging, but remember async errors bypass it.
Frequently Asked Questions
jQuery.readyException(error) runs when a function wrapped in jQuery() or jQuery(document).ready() throws synchronously. By default it re-throws the error inside a setTimeout so the console and window.onerror still see it instead of the error being swallowed.
It was added in jQuery 3.1. Older jQuery versions do not expose this hook.
Overwrite the function: jQuery.readyException = function(error) { console.error(error); }; You can log, report to a service, update UI, or also rethrow with setTimeout to keep default visibility.
No. It only handles errors thrown synchronously while the ready callback runs. Errors inside setTimeout, promises, or later event handlers are not passed to readyException.
Re-throwing on a later turn of the event loop keeps jQuery’s ready system from swallowing the exception and lets the browser’s normal error reporting (console + window.onerror) run.
Callbacks registered with $(fn), $(document).ready(fn), and equivalent ready entry points. See the .ready() and jQuery() tutorials for how ready itself works.