Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2810

debounce-throttle

Skill này làm gì

Skill này xem xét code website phản ứng với các thao tác nhanh như cuộn, đổi kích thước hoặc gõ phím. Skill dành cho lập trình viên muốn trang mượt hơn.

Khi nào nên dùng

  • ✓Khi ô tìm kiếm gửi quá nhiều yêu cầu trong lúc người dùng đang gõ.
  • ✓Khi cuộn hoặc đổi kích thước trang cảm thấy giật.
  • ✓Khi script của bạn chạy nhiều hơn mức cần thiết.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/debounce-throttle/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/debounce-throttle/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể kiểm tra các trình xử lý cuộn và gõ phím của tôi xem có gây giật không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent tìm code chạy theo các sự kiện nhanh và gợi ý debounce hoặc throttle. Debounce chờ cho đến khi thao tác dừng lại, còn throttle giới hạn tần suất code chạy.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Debounce and throttle event handlers

High-frequency events fire hundreds of times per second, causing UI jank, excessive API calls, and poor Interaction to Next Paint (INP) scores.

Quick Reference

  • Debounce: delays execution until activity stops (search inputs, form validation)
  • Throttle: limits execution rate (scroll, resize handlers)
  • Use 150-300ms delay for user input, 100ms for scroll/resize
  • Clean up event listeners to prevent memory leaks

Check

Review this JavaScript code for scroll, resize, input, mousemove, or other high-frequency event handlers that should use debounce or throttle.

Fix

Add debounce or throttle to high-frequency event handlers to limit execution rate and improve performance.

Explain

Explain the difference between debounce and throttle, and when to use each pattern for optimal performance.

Code Review

Review scripts, client components, and browser execution paths related to Debounce and throttle event handlers. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/debounce-throttle

Câu hỏi thường gặp

Debounce và throttle khác nhau thế nào?

Debounce chờ người dùng ngừng lại. Throttle chạy code theo một nhịp đều, giới hạn trong khi thao tác vẫn tiếp diễn.

Skill gợi ý độ trễ bao nhiêu?

Skill gợi ý khoảng 150 đến 300 mili giây cho gõ phím và khoảng 100 mili giây cho cuộn và đổi kích thước.

Vì sao phải dọn dẹp event listener?

Skill nói việc dọn dẹp listener ngăn rò rỉ bộ nhớ, thứ làm trang chậm dần theo thời gian.

Chi tiết

Mô tả gốc của tác giả

Use when reviewing scripts, client components, bundles, or runtime behavior related to Debounce and throttle event handlers. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2810
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự