jQuery jQuery.speed() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Plugin Utility

What You’ll Learn

The jQuery.speed() static method builds a normalized PlainObject with duration, easing, complete, and queue for custom animations. This tutorial covers three overload signatures since jQuery 1.0 and 1.1, defaults of 400 ms and "swing", speed name normalization, plugin developer patterns, comparisons with raw .animate() options and manual defaults and jQuery.fx.off, and five hands-on examples from logging defaults to building a $.fn.pulse plugin.

01

PlainObject

Normalized animation props

02

Since 1.0

Stable plugin utility

03

Three overloads

Flexible signatures

04

Defaults

400 ms, swing easing

05

Speed names

slow, fast to numbers

06

Plugin devs

Custom animate methods

Introduction

When you call .animate(), .fadeIn(), or .slideToggle(), jQuery internally normalizes the duration, easing, and callback arguments you pass. That normalization lives in jQuery.speed() — a static utility that returns a PlainObject ready for the effects engine.

Added in jQuery 1.0 (with additional overloads in 1.1), speed() is aimed at plugin developers who create new animation methods. Instead of reimplementing optional-parameter logic and default values, you call $.speed( options ) once and pass the result to .animate(). jQuery UI’s animated .addClass() follows this pattern. Defaults are duration 400 and easing "swing"; strings like "slow" map to 600 ms automatically.

Understanding the jQuery.speed() Method

Per the official jQuery API, jQuery.speed() creates an object containing properties ready for custom animation definitions. It is a static method on the global jQuery object — not something you invoke on a collection like $(selector).animate().

The returned object typically includes duration, easing, complete, and queue. jQuery fills in missing values with defaults and converts speed name strings to numeric milliseconds. Your plugin then spreads or passes those properties into .animate() without duplicating parameter hockey.

💡
Beginner Tip

Think of jQuery.speed() as a recipe formatter for animations. You hand it messy optional arguments — a number, a settings object, or duration plus easing plus callback — and it returns a clean object with duration: 400, easing: "swing", and the rest filled in consistently every time.

📝 Syntax

Three overload signatures on the global jQuery object:

jQuery
// Overload 1 - since jQuery 1.0
jQuery.speed( duration, settings )
// Overload 2 - since jQuery 1.1
jQuery.speed( duration, easing, complete )
// Overload 3 - since jQuery 1.1
jQuery.speed( settings )

Return value and defaults

  • Returns: PlainObject — normalized duration, easing, complete, queue.
  • Default duration: 400 (milliseconds) when omitted.
  • Default easing: "swing" when omitted.
  • Speed names: "slow" → 600, "fast" → 200 (same as effect methods).

Version notes

  • Added: jQuery 1.0 (duration, settings form)
  • Extended: jQuery 1.1 (duration, easing, complete and settings forms)
  • Status: Stable — documented for plugin developers in current jQuery releases.

Plugin developer pattern

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

⚡ Quick Reference

GoalCode
Default speed object$.speed(){ duration: 400, easing: "swing", ... }
Settings object overload$.speed({ duration: 800, easing: "linear", complete: fn })
Three-argument form$.speed(600, "swing", complete)
Normalize speed name$.speed("slow").duration600
Use in custom pluginvar opt = $.speed(options); $(el).animate(props, opt.duration, opt.easing, opt.complete)
Inspect queue property$.speed({ queue: false }).queuefalse

📋 jQuery.speed vs raw .animate options vs manual defaults vs jQuery.fx.off

Four ways to configure animation timing — only jQuery.speed() centralizes overload parsing and default filling for plugin authors.

jQuery.speed()
var opt = $.speed( options );
$(el).animate( props, opt.duration, opt.easing, opt.complete );

Static utility since 1.0. Normalizes three overload forms, speed names, and defaults (400 ms, swing). Returns a PlainObject for custom animation methods.

Raw .animate options
$(el).animate( props, {
  duration: 800,
  easing: "linear",
  complete: fn
});

Built-in effect methods accept options objects directly. jQuery calls speed() internally — you rarely need it for one-off app code.

Manual defaults
duration = duration || 400;
easing = easing || "swing";

Hand-rolled fallbacks duplicate jQuery logic and miss speed name strings, queue handling, and edge cases speed() already covers.

jQuery.fx.off
jQuery.fx.off = true

Global Boolean that disables all tweens when true. Unrelated to parameter normalization — overrides duration at effect runtime regardless of speed object values.

Examples Gallery

Each example demonstrates a core jQuery.speed() concept from default values to plugin patterns. Open DevTools or use the Try-it links. Example 1 logs the default PlainObject returned by $.speed() with no arguments.

📚 Getting Started

Inspect the default PlainObject and build speed objects from settings or positional arguments.

Example 1 — Default Object: Log $.speed() Returns duration 400, easing swing

Call $.speed() with no arguments and log the result. jQuery fills in duration: 400 and easing: "swing" automatically.

jQuery
var defaults = $.speed();
console.log( "duration:", defaults.duration );
console.log( "easing:", defaults.easing );
console.log( "complete:", defaults.complete );
console.log( "queue:", defaults.queue );
$( "#speed-output" ).html(
  "duration: " + defaults.duration +
  ", easing: " + defaults.easing
);
Try It Yourself

How It Works

With zero arguments, jQuery.speed() applies the same defaults effect methods use internally. This is the baseline every overload merges into before returning the PlainObject.

Example 2 — Settings Object: $.speed({ duration: 800, easing: "linear", complete: fn })

Pass a single settings PlainObject. jQuery merges your values with defaults and returns a complete options object for .animate().

jQuery
function onDone() {
  $( "#done-msg" ).text( "Animation complete!" );
}
var opt = $.speed({
  duration: 800,
  easing: "linear",
  complete: onDone
});
console.log( opt );
$( "#run-settings" ).on( "click", function() {
  $( "#settings-box" )
    .css({ left: 0 })
    .animate(
      { left: 200 },
      opt.duration,
      opt.easing,
      opt.complete
    );
} );
Try It Yourself

How It Works

The settings-only overload (since jQuery 1.1) is the most readable for plugin APIs that accept a single options argument. Unspecified properties keep their defaults.

📈 Advanced Patterns

Three-argument positional form, custom plugin methods, and speed name normalization.

Example 3 — Three-Arg Form: $.speed(600, "swing", complete) Then Use in .animate()

Match the signature of built-in effect methods: duration, easing string, and complete callback as separate arguments.

jQuery
function onComplete() {
  $( "#three-arg-status" ).text( "Done at 600 ms" );
}
var opt = $.speed( 600, "swing", onComplete );
$( "#run-three-arg" ).on( "click", function() {
  $( "#three-arg-box" )
    .css({ opacity: 0.2 })
    .animate(
      { opacity: 1 },
      opt.duration,
      opt.easing,
      opt.complete
    );
} );
Try It Yourself

How It Works

The three-argument overload mirrors how developers call .fadeIn( duration, easing, complete ). speed() converts that positional style into the same PlainObject shape as the settings form.

Example 4 — Plugin Pattern: $.fn.pulse Using $.speed(options) + .animate()

Build a reusable plugin method. Let $.speed() handle defaults and overload parsing, then chain two .animate() calls for a pulse effect.

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-btn" ).on( "click", function() {
  $( ".pulse-target" ).pulse({
    duration: 400,
    easing: "swing"
  });
} );
Try It Yourself

How It Works

This is the intended use case from the official docs. jQuery UI’s animated .addClass() delegates to speed() so plugin code stays DRY. Your plugin accepts the same flexible argument styles as native effect methods.

Example 5 — Speed Names: $.speed("slow") Normalizes to 600 ms

Pass a speed name string as the duration argument. $.speed( "slow" ) converts it to 600 milliseconds, matching .fadeIn( "slow" ) behavior.

jQuery
var slowOpt = $.speed( "slow" );
var fastOpt = $.speed( "fast" );
console.log( "slow:", slowOpt.duration );
console.log( "fast:", fastOpt.duration );
$( "#run-slow" ).on( "click", function() {
  var opt = $.speed( "slow" );
  $( "#name-box" )
    .css({ width: 40 })
    .animate({ width: 220 }, opt.duration, opt.easing );
  $( "#name-label" ).text(
    '"slow" → ' + opt.duration + " ms"
  );
} );
Try It Yourself

How It Works

Speed name resolution is shared with .animate(), .fadeIn(), and siblings. Plugin authors get correct numeric durations without maintaining their own string-to-ms lookup table.

🚀 Common Use Cases

  • Custom jQuery plugins — normalize duration, easing, and callbacks in $.fn.myEffect with one $.speed( options ) call.
  • jQuery UI-style extensions — mirror animated .addClass() by passing speed objects into internal .animate() chains.
  • Consistent defaults — rely on 400 ms and "swing" without hardcoding fallbacks in every method.
  • Speed name support — accept "slow" and "fast" in plugin APIs the same way built-in effects do.
  • Debugging animation options — log $.speed( userInput ) in DevTools to see what jQuery will actually use.
  • Queue control — set queue: false in the settings object when a plugin needs simultaneous tweens.

🧠 How jQuery.speed() Normalizes Animation Options

1

Arguments received

Plugin or internal code calls jQuery.speed() with zero to three arguments — a settings object, positional duration/easing/complete, or duration plus partial settings.

Input
2

Overload resolution

jQuery detects which signature matches. Speed name strings like "slow" convert to numeric milliseconds. Missing easing becomes "swing"; missing duration becomes 400.

Parse
3

PlainObject returned

The method returns { duration, easing, complete, queue } with all defaults filled. Plugin code passes these properties into .animate() or the fx engine directly.

Output
4

Effect runs (unless fx.off)

.animate() uses the normalized values. If jQuery.fx.off is true, the global flag overrides duration at runtime and the tween completes instantly regardless of the speed object.

📝 Notes

  • Added in jQuery 1.0 (duration, settings); extended in 1.1 with easing/complete and settings-only forms.
  • Returns a PlainObject — not a jQuery collection.
  • Default duration is 400 ms; default easing is "swing".
  • Speed names: "slow" → 600 ms, "fast" → 200 ms.
  • Intended for plugin developers creating new animation methods — built-in effects call it internally.
  • The returned object may include queue — set false for concurrent animations on the same element.
  • Separate from jQuery.fx.off, which globally disables tweens after options are normalized.

Browser Support

jQuery.speed() has been available since jQuery 1.0 (extended in 1.1) and remains supported in current jQuery 3.x releases. It is a JavaScript utility independent of browser animation APIs.

Stable · Since jQuery 1.0

jQuery.speed()

Works in every browser that runs jQuery. Normalizes options in JavaScript before the fx engine runs. Pair with .queue() to inspect how normalized animations serialize on elements.

Universal All jQuery browsers
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() Stable

Bottom line: Use speed() in plugins for consistent animation defaults. Learn .queue() next to see how normalized effects enter the fx pipeline.

Conclusion

jQuery.speed() is a static utility that returns a normalized PlainObject with duration, easing, complete, and queue for custom animations. Three overload signatures accept settings objects or positional arguments; defaults are 400 ms and "swing".

Plugin developers should call $.speed( options ) instead of duplicating parameter parsing. Application code rarely needs it directly because .animate() invokes it internally. Continue to .queue() to inspect how normalized effects serialize on the fx pipeline.

💡 Best Practices

✅ Do

  • Call $.speed( options ) at the start of custom animation plugin methods
  • Accept the same argument styles as built-in effects (settings object or positional args)
  • Log $.speed( userInput ) when debugging unexpected durations
  • Use queue: false in settings when animations must run in parallel
  • Document that your plugin honors "slow" and "fast" via speed normalization

❌ Don’t

  • Duplicate default logic manually — speed() already handles edge cases
  • Confuse speed() with fx.off — one normalizes options, one disables tweens globally
  • Call speed() on a jQuery collection — it is a static jQuery method
  • Assume app code always needs speed().animate() calls it for you
  • Forget that complete may be undefined when callers omit a callback

Key Takeaways

Knowledge Unlocked

Five things to remember about jQuery.speed()

Plugin utility for normalized animation options.

5
Core concepts
02

Since 1.0

Plugin utility

API
🔄 03

Three overloads

Flexible signatures

Syntax
📝 04

400 / swing

Default values

Defaults
05

Plugin devs

Custom methods

Pattern

❓ Frequently Asked Questions

<code>jQuery.speed()</code> returns a <code>PlainObject</code> containing normalized animation properties &mdash; typically <code>duration</code>, <code>easing</code>, <code>complete</code>, and <code>queue</code> &mdash; ready to pass into <code>.animate()</code> or a custom plugin method. It is a static utility on the global <code>jQuery</code> object, not a method on a jQuery collection.
The first overload <code>jQuery.speed( duration, settings )</code> was added in jQuery 1.0. The two-argument easing form and the settings-only form were added in jQuery 1.1. The method has remained a stable internal and plugin utility across jQuery 1.x, 2.x, and 3.x.
When you omit arguments or leave properties unset, <code>jQuery.speed()</code> applies <strong>duration <code>400</code></strong> (milliseconds) and <strong>easing <code>&quot;swing&quot;</code></strong>. Speed name strings like <code>&quot;slow&quot;</code> (600 ms) and <code>&quot;fast&quot;</code> (200 ms) are normalized to numeric durations automatically.
Plugin developers creating new animation methods should call <code>$.speed()</code> instead of duplicating parameter parsing. jQuery UI&rsquo;s animated <code>.addClass()</code> uses this pattern. Application code can call it too, but most day-to-day animation uses <code>.animate()</code>, <code>.fadeIn()</code>, or similar methods that invoke <code>speed()</code> internally.
<code>jQuery.speed( duration, settings )</code> since 1.0; <code>jQuery.speed( duration, easing, complete )</code> since 1.1; and <code>jQuery.speed( settings )</code> since 1.1. All three return the same normalized PlainObject shape with defaults filled in.
<code>jQuery.speed()</code> normalizes duration and easing for a single animation call. <code>jQuery.fx.off</code> is a separate global flag that forces all jQuery effects to skip tweens when <code>true</code>. Even a perfectly normalized speed object is overridden at effect runtime when <code>fx.off</code> is enabled.
Did you know?

jQuery UI’s animated .addClass() delegates parameter parsing to jQuery.speed() so it accepts the same duration, easing, and callback styles as .animate() without reimplementing defaults. The method has existed since jQuery 1.0 — before many of today’s CSS transition APIs. See the official reference at api.jquery.com/jQuery.speed/.

Continue to .queue()

Learn how jQuery serializes effect steps on the fx queue — the pipeline that consumes normalized speed objects.

.queue() →

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.

6 people found this page helpful