Capítulo 8 de 411

Chapter 8: gsap.config()

Core Idea

gsap.config() sets GSAP-wide behavior that isn't tied to a specific tween — performance tuning, default units, and warning behavior.

Key Concepts

  • autoSleep: frames between internal checks for powering down GSAP's ticker to save battery (default 120, ~every 2s).
  • force3D: "auto" (default) lets GSAP use 3D transforms only during active animation, true forces it always, false disables it.
  • nullTargetWarn: set false to suppress the warning GSAP logs when a tween target doesn't exist.
  • units: default unit per property when none is given (e.g. make left: 100 default to % instead of px).

Code Examples

gsap.config({
  autoSleep: 60,
  force3D: false,
  nullTargetWarn: false,
  units: { left: "%", top: "%", rotation: "rad" },
});
  • What it demonstrates: only the settings you pass get changed — omitted config values are left at their defaults.

Key Takeaways

  1. Use gsap.config() for global engine behavior; use gsap.defaults() for values that should be inherited by tweens you create afterward.
  2. force3D is a real performance trade-off, not just a flag — leave it on "auto" unless you have a measured reason to change it.

Connects To

  • gsap.defaults(): for tween-property defaults, as opposed to engine-level config.