Μετάβαση στο κύριο περιεχόμενο
← 📄 HTML & the platform·Ενότητα A7 · Μάθημα 1
ΕργασίαBuild a head with one render-blocking stylesheet (/critical.css) and one DEFERRED script (/app.js). Use <link rel='stylesheet' href='/critical.css'> and <script src='/app.js' defer></script>.

Η κρίσιμη διαδρομή απόδοσης

75 XP6 min
Θεωρία

What happens between "request sent" and "first pixel"

  1. HTML downloads — usually one round-trip.
  2. HTML parses top-to-bottom. On each <link rel="stylesheet"> and <script> (without defer/async), the parser PAUSES.
  3. CSS downloads + parses into the CSSOM.
  4. JS downloads + parses + executes (can mutate DOM).
  5. Render tree = DOM + CSSOM combined → layout → paint.

The first thing painted is "First Contentful Paint" (FCP). Every blocking resource before FCP adds to the user's perceived load time.

Three ways to UN-block

  • <script defer> — download in parallel, run AFTER HTML parsed. Default for anything below the fold.
  • <script async> — download in parallel, run AS SOON AS available (out of order). Use for analytics + truly independent scripts.
  • <link rel="stylesheet" media="print" onload="this.media='all'"> — load CSS without blocking render. For non-critical stylesheets.

What ALWAYS blocks

Stylesheets in the head (with no media="print" trick). Scripts in the head without defer/async. Synchronous <script> tags before </body>.

What doesn't block

  • <script defer> placed anywhere
  • <script async> placed anywhere
  • <link rel="preload"> (preloads, doesn't block)
  • Resources fetched by JS after page load
🔒

Εγγράψου για να αρχίσεις να προγραμματίζεις

Η θεωρία είναι ανοιχτή για όλους. Ο επεξεργαστής, η ζωντανή προεπισκόπηση και ο έλεγχος ξεκλειδώνουν με 7-ήμερη δωρεάν δοκιμή — απαιτείται κάρτα.

Εγγραφή — δωρεάν δοκιμή →

Τα πρώτα 10 μαθήματα κάθε διαδρομής είναι δωρεάν. Δεν χρειάζεται κάρτα.

← ΠροηγούμενοΕπόμενο μάθημα →

Μια συμβουλή Python ή web την ημέρα — με email

Σύντομο, γραμμένο στο χέρι, χωρίς spam. Διαγραφή με ένα κλικ.