HTML Resource Performance and Measurement
Match resource hints to actual needs
Preload declares a resource needed soon in the current document. Use the matching as destination and request settings to help reuse the resource when consumed. Preconnect prepares an origin connection, while prefetch suggests a future resource. This static head shows a local stylesheet URL; no external server is needed for the markup check.
<!doctype html><html lang="en"> <head> <title>Hints</title> <link rel="preload" href="data:text/css,p%7Bcolor%3Agreen%7D" as="style"> <link rel="stylesheet" href="data:text/css,p%7Bcolor%3Agreen%7D"> </head> <body> <p>Styled text</p> </body></html>The stylesheet applies green text; reuse is not measured.
Measure work rather than guessing
The Performance API exposes timing entries. A named performance mark records a point on the browser timeline. This small local exercise measures the existence of a mark, not a fixed elapsed duration. In actual performance investigations compare representative runs, not one artificial sample.
<output id="result"></output><script> performance.mark("lesson-ready"); const marks = performance.getEntriesByName("lesson-ready", "mark"); document.querySelector("#result").textContent = marks.length;</script>One named mark exists.
Inspect resource timing entries
Resource Timing entries expose information about loaded resources. getEntriesByType returns current buffered entries, not future ones; some cross-origin details require Timing-Allow-Origin. The standalone example checks the API shape without assuming that the local document has any external resources. Use the Network and Performance panels for actual loading investigations.
<output id="result"></output><script> const entries = performance.getEntriesByType("resource"); document.querySelector("#result").textContent = entries.every(entry => entry.entryType === "resource") ? "Resource entries inspected" : "Unexpected entry";</script>Resource entries, if present, have the expected type.
Common mistakes and practice
A preload does not apply a stylesheet or execute a script by itself. Test resource discovery, transfer and rendering separately; cache, device and network can alter results. Measure before and after a change, including layout stability and responsiveness.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Resource Performance and Measurement — Knowledge Check
Apply the security, privacy and performance concepts taught in this lesson.
Which hint targets a resource needed soon on this page?
Does preload apply CSS by itself?
What does preconnect prepare?
What exposes some restricted cross-origin timing details?
How should you judge a performance improvement?