jQuery .speed() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Effects

Definition

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).

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$.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
CallWhat it does
durationNumber (ms) or "slow" / "fast" — default 400
easingEasing name — default "swing"
completeCallback when the animation finishes (per element)
settingsObject form that can include duration, easing, complete, queue

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Accept flexible args in your plugin (duration, options object, or both).
Step 2Pass them through $.speed(…) to fill defaults.
Step 3Read opt.duration, opt.easing, and opt.complete.

Return Value

Return ValueDescription
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

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.

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().

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().

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() Method

See how jQuery lines up animations on the fx queue.

.queue() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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