การโต้ตอบจนถึงการแสดงผลถัดไป (INP)
ทำความเข้าใจ INP ซึ่งเป็น Core Web Vital ที่วัดความตอบสนองในโลกจริง วิธีคำนวณตลอดการเข้าชม และเทคนิคที่ช่วยให้การโต้ตอบรวดเร็วฉับไว
การโต้ตอบจนถึงการแสดงผลถัดไป (INP) เป็นบทเรียน Web Performance Optimization & Lighthouse ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Web Performance Optimization & Lighthouse และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Web Performance Optimization & Lighthouse มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Responsiveness as a Vital
Interaction to Next Paint (INP) measures how quickly the page visually responds to user input across the whole visit. It became a Core Web Vital, replacing First Input Delay.
INP vs FID
FID only measured the first interaction's input delay. INP is broader: it considers all interactions and the full latency through event handling and rendering, not just the initial delay.
What an Interaction Includes
Each interaction's latency spans three parts: input delay (waiting for the main thread), processing time (event handlers), and presentation delay (rendering the next frame).
How INP Is Reported
Across a visit, INP reports roughly the worst interaction latency (with an allowance for outliers on pages with many interactions), so it reflects the user's worst-case responsiveness.
The Thresholds
- Good: 200ms or less
- Needs improvement: 200-500ms
- Poor: over 500ms
The Main Thread Is the Bottleneck
Long tasks block the main thread so input cannot be handled promptly. Breaking up long JavaScript tasks is the single biggest lever for improving INP.
Yielding to the Main Thread
Break long work into chunks and yield so the browser can handle input between them. scheduler.yield() or a setTimeout based yield helps.
async function process(items) {
for (const item of items) {
handle(item);
await new Promise(r => setTimeout(r, 0));
}
}Defer Non-Urgent Work
Update the UI immediately for feedback, then run heavy work afterward. Patterns like requestAnimationFrame for visual updates and deferring analytics keep handlers short.
button.addEventListener('click', () => {
showSpinner();
setTimeout(doHeavyWork, 0);
});Reduce Rendering Cost
The presentation phase suffers from large DOM updates and expensive layout. Use content-visibility, virtualization, and minimal DOM changes to render the next frame faster.
Measuring INP
Capture INP in the field with the web-vitals library, and use the DevTools Performance panel's interaction track to see input delay, processing, and presentation for each event.
import { onINP } from 'web-vitals';
onINP(metric => console.log('INP', metric.value));Improvement Checklist
- Break up long tasks and yield.
- Defer non-urgent work after paint.
- Trim event handler work.
- Reduce DOM size and rendering cost.
Quick Check
How does INP differ fundamentally from the metric it replaced, FID?
Recap
You learned INP measures whole-visit responsiveness across input delay, processing, and presentation, with a good threshold of 200ms. Improve it by breaking up long tasks, yielding to the main thread, deferring non-urgent work, and reducing rendering cost.
คำถามที่พบบ่อย
บทเรียน “การโต้ตอบจนถึงการแสดงผลถัดไป (INP)” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การโต้ตอบจนถึงการแสดงผลถัดไป (INP)” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Web Performance Optimization & Lighthouse ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Web Performance Optimization & Lighthouse มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การโต้ตอบจนถึงการแสดงผลถัดไป (INP)”
ทำความเข้าใจ INP ซึ่งเป็น Core Web Vital ที่วัดความตอบสนองในโลกจริง วิธีคำนวณตลอดการเข้าชม และเทคนิคที่ช่วยให้การโต้ตอบรวดเร็วฉับไว คุณปฏิบัติ Web Performance Optimization & Lighthouse ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Web Performance Optimization & Lighthouse หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Web Performance Optimization & Lighthouse บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การโต้ตอบจนถึงการแสดงผลถัดไป (INP)” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Web Performance Optimization & Lighthouse นี้ได้ไหม
ได้ บทเรียน Web Performance Optimization & Lighthouse ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- รู้จัก Core Web Vitals
- เจาะลึก LCP, FID และ CLS
- การปรับปรุงตัวชี้วัดการโต้ตอบของผู้ใช้
- การโต้ตอบจนถึงการแสดงผลถัดไป (INP)