Speculation Rules are useful for improving page speed and user experience by reducing the time to interact with subsequent pages.
Speculation Modes:
#
1.Prefetch: #
- Preloads resources (e.g., scripts, styles, or pages) that might be needed in the near future.
- These resources are downloaded and stored but not executed until explicitly required.
- Ideal for preparing for user navigation without incurring high resource usage.
2. Prerender: #
- Fully renders the target page in the background.
- When the user navigates to the pre-rendered page, it loads instantly because it’s already prepared.
- More resource-intensive than prefetching but offers a faster user experience for anticipated navigation paths.
Speculation Eagerness:
#
This determines how aggressively the system speculates and prepares resources.
1. Conservative: #
- Prepares resources only for high-confidence predictions.
- Minimizes resource usage and potential performance hits but sacrifices some speed for unpredicted user paths.
2. Moderate: #
- Balances between cautious and aggressive speculation.
- Prepares a broader set of resources without being overly resource-intensive.
3. Eager: #
- Speculates aggressively by preloading or prerendering many potential resources or pages.
- Provides the fastest experience for predicted user paths but can lead to wasted resources and higher load on servers or client devices.
Prefetch with Conservative or Moderate Speculation is great for general usage with minimal risk of overloading resources.
Prerender with Eager Speculation is ideal for critical pages where speed is paramount and resource overhead is acceptable.