jQuery.noop (alias $.noop) is a shared empty function that does nothing when called (since jQuery 1.4). Official use: pass it around when an API wants a function but you have no work to do.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$.noop → function () {} (shared reference)
$.noop() → undefined (call does nothing)
// Plugin default pattern:
var onComplete = options.onComplete || $.noop;
onComplete(); // always safe to call
Call
What it does
Arguments
Accepts any; all ignored
Call return
undefined
Reference
$.noop — shared empty function
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
When a callback is optional, default it: var cb = options.cb || $.noop.
Step 2
Call cb(...) without an if (cb) guard.
Step 3
Pass $.noop (the reference) into APIs that require a function.
Return Value
Return Value
Description
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Call the Empty Function
Confirm type, return value, and that arguments are ignored.
Call freely. Init and destroy always invoke a function.
Frequently Asked Questions
jQuery.noop is a shared empty function — a function that does nothing when called. Added in jQuery 1.4. You typically pass the reference $.noop as a callback; calling $.noop() returns undefined.
Calling $.noop() returns undefined because the function body is empty. The useful part is the function reference itself — store $.noop and pass it where a callback is required.
Both run no code, but $.noop is the same function object every time. Writing function() {} creates a new function object on each expression. For default callbacks, $.noop is clearer and slightly cheaper.
Use it as the default when optional callbacks are omitted: var onComplete = options.onComplete || $.noop; Then call onComplete() safely without checking if (onComplete) every time.
Yes. $.noop is a real function, so $.isFunction($.noop) is true. That makes it safe anywhere a callback function is expected.
Yes. The empty function ignores all arguments — calling $.noop(1, 2, 3) still does nothing and returns undefined. APIs that pass event objects or data to callbacks work fine with noop.