jQuery .speed() Method

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is $.speed()?

jQuery.speed([duration] [, settings|easing] [, complete]) creates a plain object of animation properties — duration, easing, complete, queue — ready for custom animations (since 1.0; extra overloads since 1.1).

Remember
$.speed();                    // { duration: 400, easing: "swing", … }
$.speed("slow");              // duration → 600
$.speed("fast");              // duration → 200
$.speed(800, "linear", fn);   // positional form
$.speed({ duration: 800, easing: "linear", complete: fn });

// Meant for plugins — avoid re-implementing default/optional-arg logic
NeedUse
Normalize plugin options$.speed(options)
Run an animation.animate()
Disable all effectsjQuery.fx.off
Control the fx queue.queue()
Pause between steps.delay()

How to Use $.speed()

Call it once to normalize arguments, then feed the result into .animate() (or your plugin’s tween).

  1. Accept flexible args in your plugin (duration, options object, or both).
  2. Pass them through $.speed(…) to fill defaults.
  3. Read opt.duration, opt.easing, and opt.complete.
  4. Call .animate(props, opt) or pass values positionally.
  5. Remember jQuery.fx.off can still force zero-duration playback.
PieceRequired?Role
durationOptionalNumber (ms) or "slow" / "fast" — default 400
easingOptionalEasing name — default "swing"
completeOptionalCallback when the animation finishes (per element)
settingsOptionalObject form that can include duration, easing, complete, queue

Pseudocode

Pseudocode
call $.speed(args…)

parse overloads:
    settings-only object
    OR duration + settings
    OR duration + easing + complete

normalize duration:
    if "slow" → 600
    if "fast" → 200
    if missing → 400

normalize easing:
    if missing → "swing"

return {
    duration, easing, complete, queue, …
}

plugin:
    opt = $.speed(userOptions)
    $el.animate(props, opt)

Cheat Sheet

Keep these facts handy while writing effect plugins.

TopicDetail
ReturnsPlainObject (normalized options)
Default duration400 ms
Default easing"swing"
"fast"200 ms
"slow"600 ms
Since1.0 · extra overloads 1.1
AudiencePlugin / custom animation authors
Related mapjQuery.fx.speeds stores named durations

Live Preview

Inspect what $.speed() returns for defaults and named speeds.

Runs entirely in the browser — no network required.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Default Object

Call $.speed() with no arguments and inspect the filled defaults.

jQuery
var defaults = $.speed();

console.log(defaults.duration); // 400
console.log(defaults.easing);   // "swing"
console.log(defaults.queue);    // true
Try It Yourself

How It Works

  1. Call. Zero arguments means “use every default.”
  2. Fill. Duration becomes 400, easing becomes "swing".
  3. Return. You get a plain object, not a jQuery collection.
  4. Reuse. Pass that object into .animate() or a plugin.

Example 2 — Settings Object

Pass one options object — the most common plugin-friendly form.

jQuery
function onDone() {
  $("#done-msg").text("Animation complete!");
}

var opt = $.speed({
  duration: 800,
  easing: "linear",
  complete: onDone
});

$("#box").animate({ left: 200 }, opt.duration, opt.easing, opt.complete);
Try It Yourself

How It Works

  1. Merge. Your settings override defaults.
  2. Keep. Omitted keys still get default values.
  3. Animate. Use the normalized fields with .animate().
  4. Complete. The callback runs after that element finishes.

Example 3 — Duration + Easing + Complete

Positional form that mirrors native effect method signatures.

jQuery
var opt = $.speed(600, "swing", function () {
  $("#status").text("Done at 600 ms");
});

$("#box").animate({ opacity: 1 }, opt.duration, opt.easing, opt.complete);
Try It Yourself

How It Works

  1. Match. Same order as .fadeIn(duration, easing, complete).
  2. Normalize. $.speed() packs them into one object.
  3. Animate. Unpack fields into .animate().
  4. Finish. Complete runs when that tween ends.

Example 4 — Plugin Pattern

Official idea: let $.speed() handle argument hockey inside a custom method.

jQuery
$.fn.pulse = function (options) {
  return this.each(function () {
    var opt = $.speed(options);
    var $el = $(this);
    $el.animate({ opacity: 0.35 }, opt.duration, opt.easing, function () {
      $el.animate({ opacity: 1 }, opt.duration, opt.easing, opt.complete);
    });
  });
};

$(".pulse-target").pulse({ duration: 400, easing: "swing" });
Try It Yourself

How It Works

  1. Accept. Plugin takes the same flexible options users expect.
  2. Normalize. $.speed(options) fills defaults once.
  3. Tween. Chain .animate() calls with those values.
  4. DRY. You do not re-implement slow/fast/default parsing.

Example 5 — "slow" and "fast"

Named speeds map to milliseconds — same as other jQuery effects.

jQuery
$.speed("slow").duration; // 600
$.speed("fast").duration; // 200

var opt = $.speed("slow");
$("#box").animate({ width: 220 }, opt.duration, opt.easing);
Try It Yourself

How It Works

  1. Name. Pass "slow" or "fast" as duration.
  2. Lookup. jQuery maps them via its speed table.
  3. Number. The returned object has a numeric duration.
  4. Animate. Use that number like any other millisecond value.

Edge Cases & Pitfalls

Watch for these when building custom effect methods.

fx.off

jQuery.fx.off still wins

A perfect speed object does not animate if effects are globally disabled.

scope

Not a collection method

Call $.speed() / jQuery.speed() — not $("#el").speed().

complete

Complete is per element

Like other effects, the callback runs once per matched element — not once for the whole set.

names

Only built-in speed names are special

"slow" / "fast" map to ms. Unknown strings are not custom named speeds unless you extend jQuery.fx.speeds.

Browser Support

jQuery.speed() has been part of jQuery since 1.0 (extra overloads since 1.1). It works wherever your loaded jQuery version runs effects.

✓ Stable · jQuery 1.0+

jQuery.speed()

Works in every browser that runs your loaded jQuery version. Prefer a current jQuery 3.x build for modern projects.

100% With jQuery effects
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
$.speed() Universal

Bottom line: Safe utility for plugin authors. Use it to normalize options, then animate with .animate() or your own effect method.

Performance Notes

ApproachCostBest for
$.speed() once per callTinyNormalizing plugin options
Many simultaneous animationsHigherLimit concurrent tweens / respect reduced motion
Re-parsing args manuallyWastefulAvoid — that is what $.speed() replaces

$.speed() itself is cheap. Animation cost comes from the tweens you start afterward — keep durations reasonable and avoid flooding the fx queue.

Key Takeaways

  • Role: normalize duration / easing / complete for custom animations.
  • Defaults: 400 ms and "swing"; "fast"=200, "slow"=600.
  • Audience: plugin authors — UI code usually uses effect shorthands.
  • Pair with: .animate() to actually run the tween.

One line: $.speed() turns flexible animation arguments into a ready-to-use options object.

Frequently Asked Questions

jQuery.speed() returns a plain object with normalized animation options — typically duration, easing, complete, and queue — ready for .animate() or a custom plugin method. It is a static utility on jQuery, not a collection method.
When you omit values, duration defaults to 400 milliseconds and easing defaults to "swing". Speed names "slow" (600) and "fast" (200) are converted to numbers automatically.
Plugin developers creating new animation methods. Letting $.speed() handle defaults and optional parameters avoids duplicating jQuery’s argument logic. Day-to-day UI code usually calls .animate() or .fadeIn() instead, which use speed() internally.
1) jQuery.speed([duration] [, settings]) since 1.0. 2) jQuery.speed([duration] [, easing] [, complete]) since 1.1. 3) jQuery.speed(settings) since 1.1. All return the same normalized options shape.
$.speed() only normalizes options. If jQuery.fx.off is true, effects skip tweens at runtime (duration behaves like 0) even when your speed object looks correct.
Yes. Common pattern: var opt = $.speed(options); $el.animate(props, opt); — or pass opt.duration, opt.easing, and opt.complete positionally.

Next: .queue()

See how jQuery lines up animations on the fx queue.

.queue() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful