optimize-web-animations
Fungsinya
Skill ini memandu agent mengukur animasi halaman dan membuatnya lebih ringan. Cocok untuk pengembang web yang halamannya melambat seiring waktu atau memboroskan daya pada gerakan tersembunyi.
Kapan dipakai
- ✓Saat halaman web menjadi lebih lambat semakin lama dibuka.
- ✓Saat animasi terus berjalan meskipun berada di luar layar.
- ✓Saat Anda menduga halaman mengalami kebocoran memori dari timer, listener, atau efek.
Link skill
https://github.com/MengTo/Skills/blob/main/agent-skills/codex/optimize-web-animations/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Halaman landing saya makin lambat semakin lama dibuka. Temukan animasi penyebabnya dan perbaiki.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent mengukur halaman di browser terlebih dahulu, menghitung animasi dan loop yang berjalan, lalu menjeda gerakan di luar layar dan membersihkan sumber daya saat halaman menutup tampilannya. Agent mengukur ulang untuk memastikan perbaikannya berhasil.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Optimize Web Animations
Core Rule
Measure the real page before editing. The goal is not to remove motion; it is to make offscreen work stop, visible motion resume correctly, and route/unmount cleanup release long-lived resources.
Use Codex Browser when available, especially for localhost pages. Do not use Chrome unless the user explicitly asks for it.
Workflow
Inspect repo context.
- Read
AGENTS.mdor local instructions. - Run
git status --shortearly. - Find page components, animation hooks, CSS keyframes,
requestAnimationFrame,setInterval,setTimeout, canvas/WebGL/physics components, media elements, GSAP timelines/tweens, and existing visibility utilities. - Search effect cleanup for event listeners, observers, RAF loops, intervals, timers, external scripts, media streams, WebGL textures/materials/geometries/renderers, and async work that can complete after unmount.
- If the worktree is dirty, plan narrow staging from the start.
- Read
Capture a baseline in the browser.
- Open the exact route the user named.
- Profile at top, mid-page, footer/lower content, and one mobile viewport when layout could differ.
- Count CSS animations by computed
animationName,animationPlayState, and visibility. Include::beforeand::after. - Inspect canvases/WebGL elements separately; CSS profiling does not prove RAF loops have stopped.
- Record which animation names are running offscreen and the DOM owners responsible.
- For memory/leak asks, also record element/canvas/image/iframe counts, exposed JS heap metrics when available, an idle sample after 10-30 seconds, and a short route-cycle sample. If heap APIs return
nullor the Browser sandbox blocks monkey-patching, say so and rely on stable observable counts plus source audit. - Keep stress tests bounded. A Browser tab crash during profiling is evidence of overload, but do not over-attribute the cause unless reproduced by a minimal test.
- See
references/browser-profiling.mdfor a reusable Codex Browser evaluator.
Patch the smallest owner that controls the motion.
- Prefer an existing page reveal/visibility hook if the app has one.
- Otherwise add an
IntersectionObserverthat toggles a stable class such asis-offscreenon sections and animated child elements. - Pause CSS animations with targeted rules:
main > section.is-offscreen .expensive-animation,
.expensive-animation.is-offscreen {
animation-play-state: paused !important;
}
- For repeated cards or placeholders, observe the card shell and the animated descendants, not the whole document.
- For marquee/ticker tracks, pause the track when its section is offscreen.
- For skeleton loaders and pseudo-element glimmers, include
::beforeand::afterpause selectors where needed. - For canvas/WebGL/physics loops, gate the RAF loop directly:
- Start when the canvas/container intersects.
- Cancel
requestAnimationFramewhen offscreen. - Resume on re-entry.
- Disconnect observers and cancel frames on cleanup.
- Add a non-visual debug marker such as
data-animation-activewhen it helps browser verification.
- Respect
prefers-reduced-motionif the component already does, and avoid introducing React render loops for scroll/animation state. - For leak hardening:
- Clear every timeout/interval created by the effect.
- Cancel RAF before unmount and before restarting a loop.
- Disconnect
IntersectionObserver,ResizeObserver,MutationObserver, and custom subscriptions. - Remove global/window/document listeners with the same handler reference.
- Dispose Three/WebGL textures, materials, geometries, renderers, and remove renderer DOM nodes.
- Kill GSAP tweens/timelines for DOM nodes and mutable objects such as shader uniforms.
- Stop media streams and pause detached video/audio sources.
- Guard async loaders with an
isDisposedflag and dispose loaded resources if they resolve after unmount. - In React cleanup, capture
ref.currentvalues inside the effect before returning cleanup if lint warns the ref may change. - Cap physics or simulation frame deltas after visibility pauses so delayed frames do not run oversized updates.
- Verify behavior, not just builds.
- Reload the route and rerun the same top/mid/footer/mobile profiles.
- Target result:
offscreenRunningCount: 0for the page sections under test. - Confirm visible anima
Pertanyaan umum
Apakah animasinya akan dihapus?
Tidak. Tujuannya adalah menghentikan pekerjaan di luar layar dan membersihkan sumber daya, bukan menghapus gerakan.
Apakah diukur sebelum kode diubah?
Ya. Skill ini menyarankan untuk mengukur halaman yang sebenarnya sebelum mengedit.
Alat animasi apa saja yang dicakup?
Animasi CSS, loop canvas dan WebGL, efek GSAP, Three.js, dan Matter.js, timer, serta observer.
Detail
Deskripsi asli dari pembuat
Profile, audit, and optimize frontend page performance with emphasis on animation work, memory-leak risks, long-session slowdowns, CSS animations, canvas/WebGL requestAnimationFrame loops, marquees, skeletons, GSAP/Three/Matter effects, timers, listeners, and observers. Use when the user asks to make animations performant, pause offscreen animations, look for memory leaks, profile pages that slow the computer over time, fix janky scrolling, reduce CPU/GPU use, or repeat the "only play in view" optimization on React/Vite/Next/frontend pages using Codex Browser.
repo: MengTo/Skills
Popularitas
- Bintang GitHub
- 7.2k
- Peringkat
- #13339
- Lisensi
- MIT
- Diperbarui
- 1/11/2026
Komentar
- …
Skill lain dari repositori ini
3d-cloth-material
7.2kMembantu agent Anda membuat kain tenun yang realistis di Three.js, dengan anyaman benang, kilau lembut, lipatan alami, kelim, dan jahitan.
3d-falling-leaves
7.2kMembantu agent Anda menambahkan daun berguguran yang realistis ke scene 3D, dengan daun yang berputar, terbawa angin, dan digunakan ulang saat kamera bergerak.
3d-four-seasons
7.2kMembantu agent Anda menambahkan tampilan musim semi, panas, gugur, dan dingin ke scene 3D, dengan mengubah dedaunan, cahaya, langit, dan salju tanpa membangun ulang scene.
3d-high-poly-models
7.2kMembantu agent Anda membangun model 3D yang detail dengan bentuk halus dan tepi yang meyakinkan, lalu menyiapkan versi lebih ringan yang berjalan baik di web.
Skill serupa
angular-developer
280kMembantu agent Anda membuat kode Angular dan memberi saran struktur proyek. Berguna saat memulai proyek baru, membuat komponen, atau meningkatkan performa.
frontend-a11y
280kMembantu agent Anda membuat antarmuka web dapat diakses semua orang. Memastikan website dan aplikasi berfungsi baik dengan screen reader dan navigasi keyboard.
frontend-patterns
280kMembuat agent Anda menerapkan pola modern dalam frontend. Mengoptimalkan performa, mengelola state, dan mengikuti praktik terbaik React dan Next.js.