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

import-on-interaction

Skill này làm gì

Skill này rà soát mã của trang để tìm các tính năng nặng được tải trước khi có ai dùng. Skill dành cho lập trình viên muốn lần tải đầu tiên nhanh hơn.

Khi nào nên dùng

  • ✓Khi một widget chat hoặc bản đồ tải ở mỗi lần truy cập nhưng ít người dùng.
  • ✓Khi lần tải đầu tiên của trang bao gồm trình chỉnh sửa hoặc công cụ xuất mà không ai mở.
  • ✓Khi gói mã ban đầu lớn hơn nhiều so với những gì lần xem đầu tiên cần.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/import-on-interaction/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/import-on-interaction/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ể chỉ tải widget chat của tôi khi khách truy cập nhấp để mở nó không?”

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

Cách hoạt động

Agent tìm các tính năng chỉ cần sau khi nhấp, focus hoặc di chuột, và gợi ý tải chúng bằng dynamic import. Agent cũng gợi ý hiển thị phản hồi tức thì trong lúc mã đang tải.

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.

Load non-critical code on user interaction

Users should not pay the download, parse, and execution cost for features they may never use. Import-on-interaction shrinks initial JavaScript, reduces main-thread work during page load, and keeps the first view focused on content that matters immediately.

Quick Reference

  • Move non-essential code behind clicks, focus, hovers, or explicit user actions
  • Use dynamic import() so the code is absent from the initial route bundle
  • Show immediate UI feedback while the deferred chunk loads
  • Use this for chat widgets, editors, maps, filters, and export flows that are not needed on first paint

Check

Inspect this route or component for heavy modules, widgets, or third-party scripts that load on first render but are only needed after a user clicks, focuses, hovers, or opens a panel.

Fix

Move the non-critical dependency behind a user-triggered dynamic import(), add immediate loading feedback, and ensure the initial render still works without the deferred feature.

Explain

Explain import-on-interaction, why it improves initial performance, and which features are safe to defer until the user shows intent.

Code Review

Inspect event handlers, modal triggers, drawers, editors, maps, export actions, and third-party widgets. Flag code that is included in the initial bundle even though it is only needed after a user interaction, and verify the fix keeps the initial path lighter without degrading the triggered flow.


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

Rule page: https://frontendchecklist.io/rules/performance/import-on-interaction

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

Dynamic import là gì?

Đó là cách tải một đoạn mã chỉ khi cần, thay vì tải cùng lần tải trang đầu tiên.

Những tính năng nào có thể trì hoãn an toàn?

Skill nêu widget chat, trình chỉnh sửa, bản đồ, bộ lọc và luồng xuất dữ liệu không cần thiết ở lần xem đầu tiên.

Trang có còn hoạt động khi thiếu tính năng đó không?

Skill nói phần hiển thị ban đầu vẫn phải chạy được khi chưa có tính năng được trì hoãn.

Chi tiết

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

Use when reviewing slow initial loads caused by optional features. Prioritize code that is expensive to download or execute and not required for the first viewport, first input, or core task completion.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2888
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ự