Thuta Learning
Next.js
AdvancedWeb Developmentအလယ်အလတ်

Performance နှင့် Accessibility

Next.jsသင်ခန်းစာ 2340 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • LCP၊ INP၊ CLS ဆိုတဲ့ Core Web Vitals သုံးခုက ဘာကို တိုင်းလဲ ရှင်းပြနိုင်ဖို့
  • "use client" ကို component tree ရဲ့ အရွက်ဆီ ရွှေ့ပြီး browser ကို ပို့တဲ့ JavaScript ကို လျှော့နိုင်ဖို့
  • next/image နဲ့ next/font ကို layout shift မဖြစ်အောင် သုံးနိုင်ဖို့
  • Clickable div၊ label မပါတဲ့ input၊ heading အဆင့်ကျော်တာ စတဲ့ accessibility ပြဿနာတွေကို ရှာပြီး ပြင်နိုင်ဖို့

ရိုးရိုးလေး ရှင်းပြမယ်

ရိုးရိုးလေး ရှင်းရရင်

သင့် laptop အသစ်နဲ့ ရုံးက Wi-Fi မြန်မြန်မှာ app က ချက်ချင်း ပွင့်တာဟာ စာမေးပွဲ မေးခွန်းကို အဖြေကြည့်ပြီး ဖြေသလိုပါပဲ။ တကယ့် user တစ်ယောက်က မန္တလေးမှာ 4G signal အားနည်းနဲ့ ဖုန်းဟောင်းတစ်လုံးကို သုံးနေနိုင်ပါတယ်။ နောက်တစ်ယောက်က mouse မသုံးနိုင်လို့ keyboard နဲ့ပဲ သွားနေတာ၊ ဒါမှမဟုတ် screen reader နဲ့ စာကို နားထောင်နေတာ ဖြစ်နိုင်ပါတယ်။

Performance ဆိုတာ ဒီလူတွေအတွက် page မြန်မြန် ပေါ်ပြီး နှိပ်လိုက်ရင် ချက်ချင်း တုံ့ပြန်တာပါ။ Accessibility ဆိုတာ ဘယ်လို ကိရိယာနဲ့ပဲ သုံးသုံး app ကို အပြည့်အဝ သုံးနိုင်တာပါ။

Problem → Why → Solution

ပြဿနာ: mouse နဲ့ပဲ အလုပ်လုပ်ပြီး ခုန်နေတဲ့ note card

အောက်က NoteCard မှာ ပြဿနာ နှစ်ခု ပုန်းနေပါတယ်။ ပထမတစ်ခုက Delete "button" ဟာ တကယ်တော့ onClick ပါတဲ့ div ဖြစ်နေတာပါ။ Mouse နဲ့ နှိပ်ရင် အလုပ်လုပ်ပေမယ့် Tab key နဲ့ ရောက်လို့ မရ၊ Enter နှိပ်လို့ မရ၊ screen reader က button လို့လည်း မကြေညာပါဘူး။

ဒုတိယတစ်ခုက img မှာ width နဲ့ height မပါလို့ ပုံ download ပြီးမှ browser က နေရာ ဘယ်လောက်ယူရမလဲ သိပါတယ်။ အဲဒီအချိန်မှာ အောက်က စာတွေ ရုတ်တရက် အောက်ကို ခုန်ဆင်းသွားလို့ user က မှားပြီး Delete ကို နှိပ်မိနိုင်ပါတယ်။ ဒါကို layout shift လို့ ခေါ်ပါတယ်။

app/notes/note-card.tsx
"use client"; // the whole card ships to the browser just for one click

export function NoteCard({ note, onDelete }: NoteCardProps) {
  return (
    <div className="card">
      <img src={note.coverUrl} />
      <div className="title">{note.title}</div>
      <div className="btn" onClick={() => onDelete(note.id)}>Delete</div>
    </div>
  );
}

ဘာကြောင့် ဒီ code က ပြဿနာရှိတာလဲ

div က button ရဲ့ focus၊ keyboard နဲ့ role ဆိုတဲ့ built-in behaviour တွေ တစ်ခုမှ မပါပါဘူး။ Alt မပါတဲ့ ပုံကို screen reader က file နာမည်နဲ့ ဖတ်တတ်ပြီး size မပါတော့ CLS ကို တိုးစေပါတယ်။ Card တစ်ခုလုံး Client Component ဖြစ်နေလို့ click တစ်ခုအတွက် JavaScript ပိုပို့နေရပါတယ်။ Real button၊ alt၊ size နဲ့ "use client" ကို နေရာမှန် ထားတာက ဒီသုံးခုကို ဖြေရှင်းပါတယ်။

Core concept: user မြင်တဲ့ အမြန်နှုန်းနဲ့ user အားလုံး သုံးနိုင်မှု

Google ရဲ့ Core Web Vitals က user ခံစားရတဲ့ အတွေ့အကြုံကို ဂဏန်းသုံးခုနဲ့ တိုင်းပါတယ်။ ဒီဂဏန်းတွေကို user တွေရဲ့ 75th percentile (user ၁၀၀ ယောက်မှာ အနှေးဆုံး ၂၅ ယောက်ကို မထည့်ဘဲ ကျန်တဲ့ အနှေးဆုံးနေရာ) နဲ့ ကြည့်လေ့ရှိပါတယ်။ INP က 2024 မှာ FID ကို အစားထိုးပြီး Core Web Vital ဖြစ်လာခဲ့ပါတယ်။

Metricတိုင်းတာ"Good" အဆင့်
LCP (Largest Contentful Paint)အဓိက content အကြီးဆုံး ပေါ်လာချိန်2.5 စက္ကန့် အောက်
INP (Interaction to Next Paint)နှိပ်/ရိုက်ပြီး screen ပြောင်းဖို့ ကြာချိန်200 ms အောက်
CLS (Cumulative Layout Shift)Page က မမျှော်လင့်ဘဲ ခုန်တဲ့ ပမာဏ0.1 အောက်

Next.js မှာ ဒီ metric သုံးခုကို ထိန်းဖို့ အဓိက lever လေးခု ရှိပါတယ်။ ပထမ၊ Server Component က default ဖြစ်လို့ သူ့ code ကို browser ကို မပို့ပါဘူး။ "use client" ကို like button လို interactive ဖြစ်တဲ့ အရွက် component တွေမှာပဲ ထားရင် download နဲ့ hydrate လုပ်ရတဲ့ JavaScript နည်းလာပြီး INP ကောင်းလာပါတယ်။ ဒုတိယ၊ next/image က ပုံကို size မှန်မှန်နဲ့ format သင့်တော်အောင် ပြောင်းပေးပြီး width/height ကနေ နေရာကို ကြိုယူထားလို့ CLS ကို ကာကွယ်ပါတယ်။ တတိယ၊ next/font က font ကို build time မှာ download လုပ်ပြီး ကိုယ့် domain ကနေ serve လုပ်ကာ fallback font ရဲ့ size ကို ညှိပေးလို့ စာလုံး ပြောင်းတဲ့အခါ စာကြောင်းတွေ မခုန်တော့ပါဘူး။ စတုတ္ထ၊ streaming နဲ့ Suspense က နှေးတဲ့ data ကို စောင့်နေစဉ် page ရဲ့ ကျန်တဲ့ အပိုင်းကို အရင်ပြပေးပါတယ်။

Accessibility ရဲ့ အခြေခံကတော့ HTML element မှန်ကို သုံးတာပါ။ Button၊ a၊ label၊ heading တွေမှာ keyboard၊ focus နဲ့ screen reader ထောက်ပံ့မှုက အခမဲ့ ပါလာပါတယ်။ Root layout ထဲက <html> မှာ lang attribute (ဥပမာ Myanmar အတွက် "my") ထည့်ထားရင် screen reader က အသံထွက် မှန်မှန် ဖတ်ပါတယ်။ Focus ring ကို outline: none နဲ့ ဖျောက်မပစ်ပါနဲ့၊ စာနဲ့ နောက်ခံ အရောင် contrast ကိုလည်း စာသားပုံမှန်အတွက် 4.5:1 လောက် ရှိအောင် ထားပါ။

Mental model: ဖုန်းဟောင်းနဲ့ keyboard user
  1. Server ကနေ HTML အများဆုံး ပို့
  2. Interactive အရွက်မှာပဲ "use client"
  3. ပုံနဲ့ font အတွက် နေရာ ကြိုယူ
  4. Mouse မပါဘဲ Tab နဲ့ စမ်းကြည့်

Feature တစ်ခု ပြီးတိုင်း "ဖုန်းဟောင်းနဲ့ network နှေးနှေးမှာ၊ mouse မပါဘဲ ဒါကို သုံးလို့ ရမလား" လို့ မေးကြည့်ပါ။

အခြေခံ ပုံစံ: Server page ထဲက client အရွက်

tsx
import Image from "next/image";
import { InteractiveLeaf } from "./interactive-leaf"; // has "use client"
export default async function Page() { // Server Component
  const data = await getData();
  return (
    <main>
      <h1>{data.title}</h1>
      <Image src={data.imageUrl} alt="Describe the image" width={800} height={450} />
      <InteractiveLeaf id={data.id} />
    </main>
  );
}

Page က server ပေါ်မှာ data ယူပြီး HTML ထုတ်ပါတယ်။ Image က alt နဲ့ size ပါလို့ နေရာ ကြိုယူထားပြီး interactive လိုတဲ့ အပိုင်းလေးကိုပဲ client component အဖြစ် ခွဲထားပါတယ်။

ဥပမာ: accessible ဖြစ်တဲ့ save button

ဒီ SaveButton က note page ထဲက interactive ဖြစ်တဲ့ အရွက်လေး တစ်ခုပါ။ Note အကြောင်းအရာကို ပြတဲ့ page က Server Component အဖြစ် ကျန်နေပြီး state လိုတဲ့ ဒီ button ကိုပဲ client ဘက်ကို ပို့ပါတယ်။ Div မဟုတ်ဘဲ button အစစ်ကို သုံးထားတာနဲ့ aria-live region ကို သတိထားကြည့်ပါ။

tsx
"use client";
import { useState } from "react";

export function SaveButton() {
  const [status, setStatus] = useState("idle");
  return (
    <div>
      <button type="button" onClick={() => setStatus("saved")}>
        မှတ်စုသိမ်းမယ်
      </button>
      <p aria-live="polite">
        {status === "saved" ? "သိမ်းပြီးပါပြီ" : ""}
      </p>
    </div>
  );
}

Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်

  1. Client boundary at the leaf"use client";

    useState နဲ့ onClick လိုလို့ ဒီ file မှာ "use client" ထည့်ထားပါတယ်။ ဒီ component ကို import လုပ်တဲ့ page ကတော့ Server Component အဖြစ် ကျန်နေလို့ browser ကို JavaScript အနည်းငယ်ပဲ ပို့ရပါတယ်။

  2. Local stateconst [status, setStatus] = useState("idle");

    Save လုပ်ပြီးပြီလား ဆိုတဲ့ status ကို ဒီ component ထဲမှာပဲ သိမ်းပါတယ်။ "idle" ကနေ "saved" ကို ပြောင်းတာနဲ့ အောက်က စာသား update ဖြစ်ပါတယ်။

  3. A real button<button type="button" onClick={() => setStatus("saved")}>

    Button element က Tab နဲ့ focus ရ၊ Enter နဲ့ Space နဲ့ နှိပ်လို့ ရ၊ screen reader က "button" လို့ ကြေညာပါတယ်။ type="button" က form ထဲမှာ ထည့်မိရင်လည်း form ကို မတော်တဆ submit မလုပ်အောင် ကာကွယ်ပါတယ်။

  4. A live region for the result<p aria-live="polite">

    aria-live="polite" ပါတဲ့ element ရဲ့ စာ ပြောင်းသွားရင် screen reader က လက်ရှိ ဖတ်နေတာ ပြီးမှ "Saved" လို့ ကြေညာပေးပါတယ်။ ဒီ p element ကို အမြဲ render လုပ်ထားတာ အရေးကြီးပါတယ်၊ စာ ပြောင်းမှ element အသစ် ပေါ်လာရင် ကြေညာချက် လွတ်သွားတတ်လို့ပါ။

You should see
Mouse နှင့် keyboard နှစ်မျိုးလုံးသုံးနိုင်ပြီး save status ကို assistive technology သိနိုင်မည်။

Image နဲ့ font ကို နေရာ ကြိုယူခြင်း

next/image ရဲ့ Image component က width နဲ့ height (ဒါမှမဟုတ် parent ကို ဖြည့်မယ့် fill) ကို တောင်းပါတယ်။ ဒီတန်ဖိုးတွေကနေ aspect ratio ကို တွက်ပြီး ပုံ မရောက်ခင် နေရာ ကြိုယူထားလို့ CLS မဖြစ်ပါဘူး။ Screen အောက်ပိုင်းက ပုံတွေကို default အနေနဲ့ lazy load လုပ်ပါတယ်။ Page ထိပ်က LCP ဖြစ်မယ့် hero ပုံအတွက်ကတော့ ကိုယ်သုံးတဲ့ Next.js version ရဲ့ docs မှာ ပြထားတဲ့ prop (priority၊ version အသစ်တွေမှာ preload) နဲ့ ကြိုတင် load လုပ်ခိုင်းပါ။

app/layout.tsx
import { Noto_Sans_Myanmar } from "next/font/google";

const myanmar = Noto_Sans_Myanmar({ subsets: ["myanmar"], weight: ["400", "700"] });

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="my" className={myanmar.className}>
      <body>{children}</body>
    </html>
  );
}

next/font က build လုပ်တဲ့အချိန်မှာ font file ကို download လုပ်ပြီး app နဲ့အတူ serve လုပ်ပါတယ်။ ဒါကြောင့် browser က runtime မှာ Google ကို request မပို့ရဘဲ fallback font ကနေ font အစစ်ကို ပြောင်းတဲ့အခါ စာကြောင်းတွေ မခုန်အောင် size ကို ညှိပေးပါတယ်။

Client JavaScript ကို တိုင်းပြီး လျှော့ခြင်း

၁။ "use client" ကို အောက်ကို ရွှေ့ပါ

Layout ဒါမှမဟုတ် page တစ်ခုလုံးမှာ "use client" ရှိနေရင် အဲဒီကနေ import လုပ်တဲ့ component အားလုံး client bundle ထဲ ပါသွားပါတယ်။ Interactive အပိုင်းကို file သီးသန့် ခွဲပြီး အဲဒီမှာပဲ ထားပါ။

၂။ အလေးကြီးတဲ့ widget ကို နောက်မှ load လုပ်ပါ

Chart ဒါမှမဟုတ် rich text editor လို ချက်ချင်း မလိုတဲ့ component တွေကို next/dynamic နဲ့ import လုပ်ရင် သီးသန့် chunk ဖြစ်သွားပြီး လိုမှ download လုပ်ပါတယ်။ ssr: false option ကိုတော့ Client Component ထဲမှာပဲ သုံးခွင့်ရှိပါတယ်။

၃။ Bundle ကို မြင်အောင် ကြည့်ပါ

@next/bundle-analyzer လို tool က chunk တစ်ခုစီထဲ ဘယ် package တွေ ပါလဲ ပုံဆွဲပြပါတယ်။ Date library တစ်ခုလုံး ဒါမှမဟုတ် icon pack တစ်ခုလုံး ပါနေတာမျိုးကို ဒီနည်းနဲ့ တွေ့ရလေ့ရှိပါတယ်။

Keyboard နဲ့ စစ်ဆေးနည်း ငါးမိနစ်

  • Mouse ကို ဘေးချပြီး Tab နဲ့ page တစ်ခုလုံး သွားပါ။ Focus ရောက်နေတဲ့ နေရာကို အမြဲ မြင်ရရပါမယ်
  • Focus အစီအစဉ်က screen ပေါ်က အစီအစဉ်အတိုင်း ဖြစ်ရပါမယ်၊ အပေါ်အောက် ခုန်မနေရပါ
  • Button တိုင်းကို Enter နဲ့၊ checkbox ကို Space နဲ့ သုံးလို့ ရရပါမယ်။ Modal ကို Escape နဲ့ ပိတ်လို့ ရရပါမယ်
  • Input တိုင်းမှာ မြင်ရတဲ့ label ရှိပြီး error message ကို field နဲ့ ချိတ်ထားရပါမယ်
  • Heading တွေက h1 ကနေ စပြီး အဆင့် မကျော်ဘဲ ဆင်းရပါမယ် (h1 ပြီး h3 မဟုတ်ပါ)

Lighthouse 100 ဆိုတာ ပြီးပြီ မဟုတ်ပါ

Lighthouse က သင့်ကွန်ပျူတာပေါ်မှာ simulate လုပ်ထားတဲ့ lab data ပါ။ Automated accessibility check တွေက ပြဿနာ တစ်စိတ်တစ်ပိုင်းကိုပဲ ဖမ်းနိုင်ပြီး "alt စာသားက ပုံကို တကယ် ဖော်ပြလား" လို မေးခွန်းကို မဖြေနိုင်ပါဘူး။ User အစစ်တွေဆီက field data (Web Vitals) နဲ့ keyboard ဖြင့် ကိုယ်တိုင် စမ်းတာကို ပေါင်းသုံးပါ။

လက်တွေ့ project တွေမှာ

လက်တွေ့ project တွေမှာ

Product team တွေက "performance budget" သတ်မှတ်လေ့ရှိပါတယ်၊ ဥပမာ home page ရဲ့ client JavaScript က သတ်မှတ်ထားတဲ့ KB ထက် မကျော်ရ၊ LCP က 75th percentile မှာ 2.5 စက္ကန့် အောက် ဖြစ်ရ စသဖြင့်ပါ။ Pull request တစ်ခုက chart library အကြီးကြီး ထည့်လိုက်လို့ budget ကျော်သွားရင် network နှေးနှေးနဲ့ customer တစ်ယောက် မမြင်ခင် review မှာ ချက်ချင်း မြင်ရပါတယ်။

Team အများအပြားက axe လို automated checker ကို CI မှာ run ပြီး release တိုင်းမတိုင်ခင် keyboard နဲ့ ကိုယ်တိုင် ခဏ စမ်းကြည့်ကြပါတယ်။ Accessibility ကိုလည်း release checklist ထဲ ထည့်ထားပါတယ်။ Design system ရဲ့ button၊ dialog၊ form field component တွေကို တစ်ခါ accessible ဖြစ်အောင် သေချာ လုပ်ထားရင် app တစ်ခုလုံးက အဲဒီ အကျိုးကို အလိုလို ရပါတယ်။ အစိုးရ ဝန်ဆောင်မှုနဲ့ ဘဏ်လို နယ်ပယ်တွေမှာတော့ WCAG လို စံနှုန်းကို ဥပဒေအရ လိုက်နာရတာမျိုးလည်း ရှိပါတယ်။

အမှားများ

အမှားများတဲ့ အချက်တွေ

  • onClick ပါတဲ့ div ဒါမှမဟုတ် span ကို button နေရာမှာ သုံးတာ။ role="button" နဲ့ tabIndex ထည့်ပြီး keyboard handler ကိုယ်တိုင် ရေးရင်တောင် button element က အခမဲ့ ပေးတာကို ပြန်တည်ဆောက်နေရတာပါ။
  • Root layout ဒါမှမဟုတ် page အပေါ်ဆုံးမှာ "use client" ထည့်လိုက်တာ။ Interactive ဖြစ်တဲ့ အစိတ်အပိုင်း တစ်ခုအတွက် page တစ်ခုလုံးရဲ့ code နဲ့ dependency တွေ browser ဆီ ရောက်သွားပြီး Server Component ရဲ့ အကျိုးကို ဆုံးရှုံးပါတယ်။
  • Image မှာ width/height မပါဘဲ ပုံ ပေါ်လာမှ layout ခုန်တာ၊ ဒါမှမဟုတ် alt ကို "image" လို အဓိပ္ပာယ်မဲ့ စာနဲ့ ဖြည့်တာ။ အလှဆင်ပုံသက်သက်ဆိုရင် alt="" ထားပြီး screen reader ကို ကျော်ခိုင်းပါ။
  • Design ကြည့်ကောင်းအောင် outline: none နဲ့ focus ring ကို ဖျောက်ပစ်ပြီး အစားထိုး focus style မထည့်တာ။ Keyboard user တွေ လက်ရှိ ဘယ်ရောက်နေလဲ မသိတော့ပါဘူး။

Mini challenge

ကိုယ်တိုင် လုပ်ကြည့်ရအောင်: accessibility audit သေးသေးလေး

Page တစ်ခုရဲ့ element တွေကို ရိုးရှင်းတဲ့ object list အဖြစ် လက်ခံပြီး ဒီ lesson မှာ ပြောခဲ့တဲ့ ပြဿနာတွေကို ရှာပေးတဲ့ audit function ကို ရေးပါ။ "before" page မှာ ပြဿနာတွေ တွေ့ရပြီး ပြင်ထားတဲ့ "after" page မှာ 0 ဖြစ်ရပါမယ်။

  • alt attribute လုံးဝ မပါတဲ့ img ကို သတိပေးပါ (alt="" က အလှဆင်ပုံအတွက် မှန်ပါတယ်)
  • စာသားလည်း aria-label လည်း မပါတဲ့ button ကို သတိပေးပါ
  • htmlFor နဲ့ ချိတ်ထားတဲ့ label မရှိ၊ aria-label လည်း မပါတဲ့ input ကို သတိပေးပါ
  • Heading အဆင့် ကျော်တာ (h1 ပြီး h3) နဲ့ onClick ပါတဲ့ div/span ကို သတိပေးပါ
a11y-audit.ts
type El = {
  tag: string;
  text?: string;
  alt?: string;
  ariaLabel?: string;
  id?: string;
  htmlFor?: string;
  src?: string;
  onClick?: boolean;
};

export function audit(page: El[]): string[] {
  const issues: string[] = [];
  // TODO: collect the ids that some <label htmlFor> points at
  // TODO: walk the elements and remember the last heading level
  // TODO: push one readable message per problem, e.g. "#3 <input> has no label"
  return issues;
}

// TODO: build a "before" page with problems and a fixed "after" page,
// then print the number of issues and each message for both

ရလဒ်: "before: 4 issue(s)" နဲ့ အောက်မှာ alt မပါတဲ့ img၊ h1 ကနေ h3 ကျော်တာ၊ label မပါတဲ့ input၊ clickable div ဆိုတဲ့ စာကြောင်း လေးကြောင်း ပေါ်ပြီး "after: 0 issue(s)" ဖြစ်ပါတယ်။

အရိပ်အမြွက် ကြည့်ရန်

Heading level ကို /^h([1-6])$/ regex နဲ့ ဖမ်းပါ။ Level အသစ်က အရင် heading ထက် 1 ထက်ပိုပြီး ကြီးနေရင် ကျော်တာပါ။ alt === undefined နဲ့ alt === "" ကို ခွဲစစ်ဖို့ မမေ့ပါနဲ့။

အဖြေ ကြည့်ရန်
a11y-audit.ts
type El = {
  tag: string;
  text?: string;
  alt?: string;
  ariaLabel?: string;
  id?: string;
  htmlFor?: string;
  src?: string;
  onClick?: boolean;
};

export function audit(page: El[]): string[] {
  const issues: string[] = [];
  const labels = page.filter((el) => el.tag === "label");
  const labelled = new Set(labels.map((el) => el.htmlFor));
  let lastHeading = 0;

  page.forEach((el, i) => {
    const at = `#${i} <${el.tag}>`;
    const level = /^h([1-6])$/.exec(el.tag);
    if (level) {
      const n = Number(level[1]);
      if (n > lastHeading + 1) {
        issues.push(`${at} skips from h${lastHeading} to h${n}`);
      }
      lastHeading = n;
    }
    if (el.tag === "img" && el.alt === undefined) {
      issues.push(`${at} has no alt attribute`);
    }

    if (el.tag === "button" && !el.text?.trim() && !el.ariaLabel) {
      issues.push(`${at} has no accessible name`);
    }
    if (el.tag === "input" && !el.ariaLabel && !(el.id && labelled.has(el.id))) {
      issues.push(`${at} has no label`);
    }
    if ((el.tag === "div" || el.tag === "span") && el.onClick) {
      issues.push(`${at} is clickable but not a <button>`);
    }
  });
  return issues;
}

const before: El[] = [
  { tag: "h1", text: "Myanmar Notes" },
  { tag: "img", src: "/logo.png" },
  { tag: "h3", text: "Recent notes" },
  { tag: "input", id: "search" },
  { tag: "button", ariaLabel: "Search" },
  { tag: "div", text: "Delete", onClick: true },
  { tag: "img", src: "/divider.svg", alt: "" },
];

const after: El[] = [
  { tag: "h1", text: "Myanmar Notes" },
  { tag: "img", src: "/logo.png", alt: "Myanmar Notes logo" },
  { tag: "h2", text: "Recent notes" },
  { tag: "label", text: "Search notes", htmlFor: "search" },
  { tag: "input", id: "search" },
  { tag: "button", text: "Delete" },
];

for (const [name, page] of [["before", before], ["after", after]] as const) {
  const issues = audit(page);
  console.log(`${name}: ${issues.length} issue(s)`);
  issues.forEach((issue) => console.log(`  - ${issue}`));
}

Quick Quiz 1 / 3

Note card ထဲက cover ပုံ load ဖြစ်ပြီးမှ စာတွေ အောက်ကို ခုန်ဆင်းသွားတယ်။ ဘယ် metric ကို ထိခိုက်ပြီး ဘယ်လို ပြင်ရမလဲ။

Quick Quiz 2 / 3

<div onClick={remove}>Delete</div> ကို accessible ဖြစ်အောင် အကောင်းဆုံး ပြင်နည်းက ဘာလဲ။

Quick Quiz 3 / 3

Notes page က Server Component ဖြစ်ပြီး ထဲမှာ like button တစ်ခုပဲ state လိုတယ်။ "use client" ကို ဘယ်မှာ ထားသင့်လဲ။

မှတ်ထားရမယ့် အချက်များ

  • LCP က အဓိက content ပေါ်ချိန်၊ INP က တုံ့ပြန်မှု၊ CLS က layout ခုန်တာကို တိုင်းပါတယ်
  • "use client" ကို interactive အရွက်မှာပဲ ထားပြီး client JavaScript ကို လျှော့ပါ
  • next/image မှာ size နဲ့ alt ပေးပြီး next/font နဲ့ font ကို self-host လုပ်ပါ
  • Button၊ label၊ heading မှန်မှန်သုံးပြီး mouse မပါဘဲ Tab နဲ့ ကိုယ်တိုင် စမ်းပါ

Next.js — Production Checklist — Next.js

Next.js — Production Checklist — Next.js

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Performance နှင့် Accessibility | Thuta Learning