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

import-on-visibility

Skill này làm gì

Skill này rà soát các trang dài và nguồn cấp nội dung có phần nặng tải trước khi chúng hiển thị. Skill dành cho lập trình viên xây trang nhiều nội dung.

Khi nào nên dùng

  • ✓Khi một trang dài tải biểu đồ hoặc đánh giá mà hầu hết khách không cuộn tới.
  • ✓Khi nguồn cấp hoặc bảng điều khiển gửi mã cho các khung nằm xa phía dưới trang.
  • ✓Khi việc cuộn bị giật khi các phần nặng xuất hiện.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/import-on-visibility/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-visibility/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 phần đánh giá trên trang của tôi khi khách truy cập cuộn gần tới 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 thành phần ngoài màn hình đang tải sớm và gợi ý tải chúng khi chúng tiến gần vùng hiển thị, bằng Intersection Observer. Agent cũng gợi ý dùng placeholder để bố cục không bị nhả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.

Load non-critical code when content approaches the viewport

Many pages ship JavaScript for offscreen sections that a user may never reach. Import-on-visibility keeps the initial route lighter while still loading content early enough to feel ready when users scroll to it.

Quick Reference

  • Use Intersection Observer to start loading code before an offscreen section becomes visible
  • Reserve space with placeholders or skeletons so deferred sections do not cause layout shift
  • Tune rootMargin so heavy content loads early enough without competing with above-the-fold work
  • Use this for charts, reviews, related products, embeds, and offscreen dashboards

Check

Identify components, widgets, or modules that load on first render even though they only appear after the user scrolls. Flag which ones can switch to visibility-based loading.

Fix

Use Intersection Observer or an equivalent framework primitive to load the offscreen component or dependency when it approaches the viewport, while preserving layout stability and a clear placeholder.

Explain

Explain import-on-visibility, how it differs from import-on-interaction, and how viewport-based loading helps large pages stay fast.

Code Review

Inspect scroll-triggered sections, embeds, charts, recommendation modules, and long landing pages. Flag code that is bundled eagerly even though the corresponding UI stays offscreen until later, and verify the deferred version still loads before the user reaches it.


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

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

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

Intersection Observer là gì?

Đó là tính năng của trình duyệt báo khi một phần tử tiến gần hoặc đi vào vùng nhìn thấy.

Khác gì so với tải khi nhấp?

Cách này tải mã khi phần đó tiến gần màn hình, còn tải khi nhấp thì chờ khách truy cập thực hiện hành động.

Vì sao cần placeholder?

Skill nói placeholder giữ bố cục ổn định để các phần được trì hoãn không gây dịch chuyển bố cục.

Chi tiết

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

Use when reviewing long pages, dashboards, or content feeds with expensive offscreen modules. Balance early enough loading for smooth scrolling against keeping the initial route light.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

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