Course contentsShow
← Web Development
Lesson 2123 of 2,98239. Network PerformanceFree lesson

Stream Prioritization in HTTP/2

Learn how HTTP/2 allows clients to prioritize resource loading for optimal page rendering.

Stream Prioritization in HTTP/2

You'll learn how HTTP/2 lets clients tell servers which resources matter most for fast page rendering.

In HTTP/2, every resource request creates a "stream" (as you learned with multiplexing). But not all resources are equally important—your CSS is more critical for rendering than a tracking script. Stream prioritization allows the browser to assign weights and dependencies to these streams, telling the server "send this first, that second."

How It Works

Think of it like a restaurant kitchen with multiple orders. The chef could prepare dishes in the order they arrived, but it's smarter to prioritize the appetizers before desserts for the same table. Similarly, browsers create a dependency tree where critical resources (like CSS blocking render) get higher priority than optional images.

Streams can have:

  • Weight (1-256): Higher numbers = more bandwidth share
  • Dependencies: "Don't send this stream until that one completes"

For example, a browser might say: "Give CSS weight 220, JavaScript weight 110, and images weight 32." The server allocates bandwidth proportionally, ensuring CSS arrives roughly twice as fast as JavaScript.

Why This Matters for Performance

Without prioritization, your hero image might arrive before the stylesheet needed to display it correctly. With prioritization, browsers guide servers to deliver resources in the optimal order for fast First Contentful Paint and Time to Interactive.

The beauty? This happens automatically. Modern browsers implement smart default prioritization strategies. However, as a developer, understanding this helps you architect pages that benefit from these defaults—placing critical CSS in <head>, deferring analytics, and structuring resource dependencies logically.

Key Takeaway: HTTP/2 stream prioritization lets clients guide servers on which resources to send first, ensuring critical rendering resources arrive before less important ones for faster page loads.