.resize() is jQuery’s legacy shorthand (since 1.0) for binding or triggering the browser resize event — typically on window. It is deprecated since 3.3 but still works in jQuery 3.x. Prefer .on("resize") / .trigger("resize").
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// Deprecated (since 3.3) — still works in jQuery 3.x
$(window).resize(function () {
// viewport size changed
});
$(window).resize(); // trigger
// Modern replacements
$(window).on("resize", handler);
$(window).trigger("resize");
Call
What it does
window
Standard target for viewport resize
handler
function(event)
eventData
Extra data as event.data
Debounce
Limit how often expensive work runs
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Bind with $(window).resize(handler) (legacy) or .on("resize", handler) (preferred).
Click #run → .resize() fires the event
Bound handler runs without a real window drag
How It Works
Bind. The handler is registered first.
Click. No-arg .resize() triggers the event.
Run. Bound handlers execute immediately.
Frequently Asked Questions
The .resize() method has two roles. With a handler — .resize(handler) or .resize(eventData, handler) — it binds a function that runs when the browser viewport changes size. Bind on $(window). With no arguments — .resize() — it triggers the resize event. Both forms exist since jQuery 1.0; binding is deprecated since 3.3.
Deprecated, not removed. Binding signatures are deprecated since jQuery 3.3 — use .on("resize", handler) instead. Unlike .error(), which was removed in jQuery 3.0, .resize() still works in jQuery 3.x. Prefer .trigger("resize") over no-arg .resize() for clarity.
.resize(handler) registers a callback and does not fire immediately. .resize() with no arguments triggers the resize event on each matched element — the same as .trigger("resize"). Always bind on $(window) for viewport size changes.
Replace .resize(fn) with .on("resize", fn). Replace .resize(data, fn) with .on("resize", data, fn). Replace no-arg .resize() with .trigger("resize"). Cleanup with .off("resize"). Under the hood, .resize(handler) already delegates to .on("resize").
Yes. jQuery 3.x keeps .resize() for backward compatibility. Docs mark it deprecated since 3.3 to steer new projects toward .on() and .trigger(). Prefer the modern API in the jQuery resize event tutorial.
Yes. Browsers may fire resize continuously while the user drags a window edge. Wrap expensive layout work in debounce or throttle, whether you use legacy .resize(fn) or modern .on("resize", fn).