Resource Hints Explained: preload, prefetch and preconnect
Understand preload, prefetch and preconnect, how resource hints work, when to use each hint and common performance optimization mistakes.
Resource hints are browser instructions that help a web page communicate which network resources are likely to be important. They allow developers to influence when browsers establish connections, discover resources or fetch files that may be needed soon.
The most commonly used resource hints include preload, prefetch and preconnect. Although they all relate to performance, they solve different problems. Preload tells the browser that a resource is important for the current page, prefetch suggests that a resource may be needed for a future navigation, and preconnect allows the browser to establish an early connection to an external origin.
Using resource hints correctly can reduce delays for important assets, but adding hints without a clear reason can waste bandwidth, compete with more important resources or make performance worse. The goal is not to preload or prefetch everything, but to help the browser prioritize resources that matter.
What Are Resource Hints?
A resource hint is a piece of information provided to the browser about a resource or origin that may be useful during page loading. Hints are commonly expressed with link elements in HTML and can also be provided through HTTP response headers in situations where header-based delivery is appropriate.
<link rel="preload" href="/fonts/app.woff2" as="font" crossorigin>
<link rel="prefetch" href="/next-page.html">
<link rel="preconnect" href="https://cdn.example.com">The browser remains responsible for deciding how and when to act on hints. A resource hint is therefore not simply an unconditional command to download something immediately. It provides information that can influence the browser's loading strategy.
Why Resource Hints Matter
Browsers already perform sophisticated resource discovery and prioritization. However, important resources are sometimes difficult to discover early because they are referenced indirectly through CSS, JavaScript, fonts, third-party services or dynamically generated application code.
- Start important resource downloads earlier.
- Reduce connection setup delays.
- Improve discovery of critical resources.
- Prepare connections to external origins.
- Improve navigation to likely future pages.
- Reduce delays caused by resources discovered late in the loading process.
The Main Resource Hints
| Hint | Primary Purpose | Typical Use |
|---|---|---|
| preload | Fetch an important resource for the current page | Critical fonts, images, scripts or styles |
| prefetch | Fetch a resource that may be needed later | Likely next-page resources |
| preconnect | Establish an early connection to an origin | Important third-party origins |
These hints should not be considered interchangeable. Choosing the wrong hint can result in unnecessary network activity or a resource being prioritized at the wrong time.
Preload Explained
The preload hint tells the browser that a resource is important for the current page and should be discovered and fetched earlier than normal resource discovery might allow.
<link
rel="preload"
href="/fonts/inter-regular.woff2"
as="font"
type="font/woff2"
crossorigin
>Preload is useful when the browser might otherwise discover an important resource too late. A common example is a font referenced from a CSS file. The browser may need to download the CSS before it discovers the font, while a preload hint allows the font request to be initiated earlier.
When to Use Preload
Preload is most appropriate for resources that are important to the current page and that the browser would otherwise discover later than desired. The resource should have a clear role in the initial rendering or execution process.
- Critical fonts required for initial text rendering.
- Important hero images that are part of the initial viewport.
- Critical scripts when early loading is necessary.
- Important stylesheets or other resources that are discovered late.
- Resources whose importance is known before normal discovery occurs.
The as Attribute
The as attribute tells the browser what type of resource is being preloaded. This information helps the browser apply the appropriate priority, security rules and request behavior.
| as Value | Resource Type |
|---|---|
| script | JavaScript |
| style | CSS |
| font | Web font |
| image | Image |
| fetch | Fetch or API resource |
| worker | Web worker |
| document | HTML document |
<link rel="preload" href="/app.js" as="script">
<link rel="preload" href="/styles.css" as="style">
<link rel="preload" href="/hero.webp" as="image">Using the correct as value is important because the browser uses the resource type when processing the preload request. For fonts and cross-origin resources, additional attributes may also be required so that the preload request matches the eventual resource request.
Preload Fonts
Fonts are a common preload candidate because they may be discovered only after the browser downloads and parses CSS. If a font is critical for the initial page, preloading it can reduce the time before the browser has access to the required font file.
<link
rel="preload"
href="/fonts/site.woff2"
as="font"
type="font/woff2"
crossorigin
>Preload Images
An important image can sometimes be difficult for the browser to discover early, particularly when it is referenced through CSS or generated dynamically. A preload hint can make the browser aware of the image sooner.
<link
rel="preload"
href="/images/hero.webp"
as="image"
>Image preloading should be used selectively. If an image is already discoverable quickly through a normal img element, adding preload may provide little benefit while still competing with other resources.
Prefetch Explained
Prefetch tells the browser that a resource may be needed in the future. Unlike preload, which is intended for the current page, prefetch is commonly used for resources associated with a likely future navigation or interaction.
<link rel="prefetch" href="/pricing.html">For example, if a user is viewing a landing page and there is strong evidence that the next navigation is likely to be a pricing page, the application can provide a prefetch hint for the future document or resources associated with that navigation.
When to Use Prefetch
- Resources needed by a likely next navigation.
- Pages that users are highly likely to open next.
- Assets required by a predictable future interaction.
- Resources that are not critical to the current page but may improve a future navigation.
Prefetch is especially useful when there is a reasonable prediction about what the user will do next. It should not be used simply because a resource might be useful at some point in the future.
Preload vs Prefetch
| Characteristic | Preload | Prefetch |
|---|---|---|
| Target | Current page | Future navigation or interaction |
| Purpose | Fetch an important resource earlier | Prepare for possible future use |
| Priority | Intended for important current resources | Generally lower priority |
| Typical example | Critical font | Likely next page |
| Main risk | Competing with critical resources | Wasting bandwidth on unused resources |
Preconnect Explained
Preconnect allows the browser to begin establishing a connection to another origin before the page actually needs to request a resource from that origin. This can reduce connection setup latency for important third-party or cross-origin resources.
<link rel="preconnect" href="https://cdn.example.com">Depending on the connection and protocol, establishing communication with an origin can involve DNS resolution, a TCP connection and TLS negotiation. Preconnect allows some of this work to happen earlier.
When to Use Preconnect
Preconnect is useful when the page knows that it will soon request an important resource from another origin. Common examples include a CDN, font provider, image service or critical API endpoint.
- Important CDN origins.
- Critical third-party font providers.
- External image services used above the fold.
- Important API origins.
- Other cross-origin resources required early during page loading.
Preconnect vs DNS Prefetch
DNS prefetch and preconnect both prepare for future network activity, but they operate at different levels. DNS prefetch focuses on resolving a hostname, while preconnect can prepare a broader portion of the connection process.
<link rel="dns-prefetch" href="//cdn.example.com">
<link rel="preconnect" href="https://cdn.example.com">Preconnect generally provides a stronger form of connection preparation, but it also requires more resources. DNS prefetch can therefore be useful when there are many potential origins or when establishing a complete connection early would not be justified.
Resource Hints and the Critical Rendering Path
Resource hints can affect the critical rendering path by changing when important resources become available. Preloading a critical font or image may allow the browser to obtain it earlier, while preconnecting to a required CDN can reduce the delay before its request begins.
HTML response
↓
Resource discovery
↓
Download critical resources
↓
Parse and execute
↓
Render pageThe most effective hint is the one that removes a real bottleneck from this sequence. If a resource is already discovered early and downloaded quickly, adding another hint may not improve the final rendering result.
Resource Hints and LCP
Resource hints can sometimes improve Largest Contentful Paint when they help the browser discover or connect to a resource that is directly involved in rendering the largest visible content element.
For example, if the LCP element is an important hero image that is otherwise discovered late, a carefully chosen preload may reduce its discovery delay. However, if the image is already requested immediately through HTML, the benefit may be negligible.
Resource Hints and Fonts
Fonts can influence text rendering and visual stability, making them a common performance optimization target. Preload can be helpful when a specific font is required early and would otherwise be discovered late through CSS.
At the same time, font files should be kept efficient. Loading unnecessary font families, weights or character sets can create more network work than the preload optimization saves.
Resource Hints in HTTP Headers
Resource hints can also be communicated through HTTP response headers. This can be useful when the server knows about an important resource before the browser has parsed the HTML document.
Link: </fonts/app.woff2>; rel=preload; as=font; crossorigin
Link: <https://cdn.example.com>; rel=preconnectHTML link elements are often easier to understand and maintain for page-specific resources, while response headers can be useful when infrastructure or application logic needs to provide the hint before HTML parsing begins.
Preload and Caching
Preload does not replace caching. A resource that is already available from an effective cache may not need to be fetched from the network, while a preload can help discover a resource sooner when a network request is required.
Cache behavior should therefore be considered when evaluating a preload optimization. A resource may appear faster during repeated visits because of caching even though the initial network request has not improved.
Resource Hints and CDNs
CDNs are common targets for preconnect because pages frequently load images, scripts, fonts or other assets from separate origins. Establishing a connection early can reduce the time before those resources begin transferring.
<link rel="preconnect" href="https://cdn.example.com">The origin should be specified exactly as required by the resource request. If the page requests a resource from one origin but preconnects to a different origin, the connection preparation will not provide the intended benefit.
Cross-Origin Credentials
Cross-origin resources can have credential requirements that affect how the browser handles requests. In particular, font preloads commonly use the crossorigin attribute so that the preload request matches the eventual font request and can be reused correctly.
<link
rel="preload"
href="https://cdn.example.com/font.woff2"
as="font"
crossorigin
>Common Resource Hint Mistakes
Resource hints are powerful because they can influence browser behavior. That also makes incorrect usage potentially harmful. The most common mistakes involve hinting at too many resources or using a hint for the wrong purpose.
- Preloading resources that are not required for the current page.
- Using preload for resources that are already discovered early.
- Using prefetch for resources that are unlikely to be requested.
- Preconnecting to too many third-party origins.
- Using the wrong as attribute with preload.
- Forgetting crossorigin requirements for cross-origin fonts.
- Assuming every resource hint guarantees a specific download order.
- Adding hints without measuring whether they improve real performance.
Preload Everything Is Not a Good Strategy
A common mistake is treating preload as a way to make every resource load as early as possible. Browsers already prioritize resources based on their expected importance, and forcing too many resources into early loading can create competition for bandwidth.
For example, preloading several images, fonts and JavaScript files at the same time can prevent the browser from efficiently prioritizing the resource that actually determines the user's first meaningful view.
Prefetching Too Aggressively
Prefetch is based on a prediction about future use. If the prediction is wrong, the browser may download data that the user never needs. This is especially important on constrained connections and devices where unnecessary downloads consume bandwidth and resources.
Prefetch is most useful when there is strong evidence that a resource is likely to be needed soon. Navigation patterns, application state and user interactions can provide better signals than simply prefetching every linked page.
Too Many Preconnect Hints
Each connection consumes resources. Adding preconnect hints for every external service on a page can cause unnecessary connection setup and may reduce the benefit of preconnecting to the most important origin.
| Problem | Better Approach |
|---|---|
| Preload every image | Preload only critical late-discovered images |
| Prefetch every link | Prefetch likely future navigation |
| Preconnect every origin | Preconnect critical external origins |
| Preload all fonts | Preload only fonts needed immediately |
| Add hints without testing | Measure before and after |
How to Choose the Right Hint
| Question | Recommended Hint |
|---|---|
| Is this resource important for the current page? | preload |
| Could this resource be needed on the next page? | prefetch |
| Will the page soon request something from another origin? | preconnect |
| Is only DNS resolution useful in advance? | dns-prefetch |
This simple decision process prevents many resource hint mistakes. First identify when the resource is needed, then determine whether the bottleneck is resource discovery, connection establishment or future navigation.
Resource Hints and Browser Priorities
Resource hints provide additional information to the browser, but developers should not assume that hints completely override the browser's internal scheduling and prioritization logic. The browser ultimately manages network requests according to its own loading model and available resources.
This is why performance testing is essential. A hint that improves one page can have little effect on another page with different resource dependencies, network conditions or caching behavior.
How to Test Resource Hints
The impact of a resource hint should be measured using browser developer tools and performance testing tools. Compare the page with and without the hint and examine when the relevant request starts, when it completes and whether important rendering milestones improve.
- Inspect the browser Network panel.
- Check when the hinted resource begins downloading.
- Compare request priority and timing.
- Measure FCP and LCP when relevant.
- Test cold and repeat visits.
- Test realistic mobile and desktop conditions.
- Compare different geographic locations when external origins are involved.
Resource Hints and Mobile Performance
Resource hints can be particularly sensitive on mobile networks because bandwidth and connection capacity may be limited. An optimization that appears harmless on a fast desktop connection can create unnecessary competition on a slower device.
For this reason, preloading and prefetching should be evaluated using realistic mobile conditions. Avoid assuming that more simultaneous downloads always produce a faster experience.
Best Practices
- Use preload only for important current-page resources.
- Use prefetch for resources likely to be needed in the future.
- Use preconnect for critical cross-origin connections.
- Keep the number of hints small and intentional.
- Use the correct as attribute for preloaded resources.
- Handle cross-origin fonts with the appropriate CORS behavior.
- Avoid preloading resources that are already discovered efficiently.
- Test resource hints on realistic devices and networks.
- Measure actual rendering improvements rather than request timing alone.
- Remove hints that no longer provide a measurable benefit.
Resource Hint Quick Reference
| Hint | Use It For | Avoid Using It For |
|---|---|---|
| preload | Critical current-page resources | Every asset on the page |
| prefetch | Likely future resources | Unlikely future requests |
| preconnect | Important external origins | Every third-party domain |
| dns-prefetch | Early DNS resolution | Replacing necessary connection optimization |
Frequently Asked Questions
What is the difference between preload and prefetch?
Preload is intended for an important resource needed by the current page, while prefetch is intended for a resource that may be needed by a future navigation or interaction.
What does preconnect do?
Preconnect allows the browser to begin establishing a connection to an origin before the page actually requests a resource from it. This can reduce connection setup latency for important cross-origin resources.
Should I preload all fonts?
No. Preload only fonts that are actually required early during the initial page load. Preloading unnecessary fonts can waste bandwidth and compete with more important resources.
Can preload improve LCP?
Yes, in some situations. If the LCP resource is difficult to discover early, such as an important image referenced indirectly, preload can reduce its discovery delay. The benefit should be verified with performance measurements.
Does prefetch always download the resource?
A prefetch hint is a suggestion to the browser rather than a guarantee that the resource will be downloaded immediately. The browser decides whether and when to use the hint based on its own scheduling and resource conditions.
Can I use preload and preconnect together?
Yes. They solve different problems. Preconnect can prepare the connection to an external origin, while preload can identify a specific important resource that should be fetched early.
How many preconnect hints should I use?
There is no universal number, but they should be limited to important origins that the page will actually use early. Excessive preconnect hints can consume connection resources without providing meaningful benefits.
Can resource hints make a website slower?
Yes. Incorrect or excessive hints can consume bandwidth, create network competition and cause less important resources to be fetched too early. Resource hints should therefore be measured rather than added indiscriminately.
Helpful Performance Tools
An HTML Formatter helps inspect and format HTML containing resource hint declarations, an HTTP Header Viewer can help inspect response headers that provide loading information, a CDN URL Generator assists with constructing CDN resource URLs, a Cache-Control Generator helps create cache directives for resources, and a URL Builder can simplify the construction of resource URLs used by web applications.
Conclusion
Resource hints give developers a way to provide browsers with additional information about important resources and network origins. Preload is designed for important resources needed by the current page, prefetch prepares for likely future use, and preconnect reduces connection setup delays for important external origins.
The best results come from using these hints selectively. Preloading too many resources, prefetching unlikely content or connecting to unnecessary origins can waste bandwidth and reduce the effectiveness of browser prioritization.
By identifying genuine discovery and connection bottlenecks, choosing the appropriate hint and measuring the result under realistic network conditions, developers can use preload, prefetch and preconnect as targeted performance optimizations rather than as generic ways to make every resource load earlier.