|
2 | 2 | '@builder.io/qwik': minor
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -PERF: Prefetching now happens dynamically without service worker if the prefetchImplementation is set to "html-append" (default). |
6 |
| -PERF: Initial prefetching now includes dynamic imports, which improves initial click delay. |
| 5 | +FEAT: Major improvements to prefetching with automatic bundle preloading |
| 6 | + |
| 7 | +- This removes the need for service workers, and instead utilize `modulepreload` link tags for better browser integration. |
| 8 | +- Improves initial load performance by including dynamic imports in the prefetch |
| 9 | +- Reduces complexity while maintaining similar (and even better) functionality |
| 10 | +- Enables some preloading capabilities in dev mode (SSR result only) |
| 11 | +- Includes path-to-bundle mapping in bundle graph (this improves the experience using the `<Link>` component, AKA "single page app" mode) |
| 12 | +- Server now has built-in manifest support (so no need to pass `manifest` around) |
| 13 | +- Moves insights-related build code to insights plugin |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +⚠️ **ATTENTION:** |
| 18 | + |
| 19 | +**Keep** your service worker code as is (either `<ServiceWorkerRegister/>` or `<PrefetchServiceWorker/>`). |
| 20 | + |
| 21 | +This new implementation will use it to uninstall the current service worker to reduce the unnecessary duplication. |
| 22 | + |
| 23 | +The builtin service workers components are deprecated but still exist for backwards compatibility. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +You can configure the prefetch behavior in your SSR configuration: |
| 28 | + |
| 29 | +```ts |
| 30 | +// entry.ssr.ts |
| 31 | +export default function (opts: RenderToStreamOptions) { |
| 32 | + return renderToStream(<Root />, { |
| 33 | + prefetchStrategy: { |
| 34 | + implementation: { |
| 35 | + // Enable debug logging for prefetch operations |
| 36 | + debug: true, |
| 37 | + // Maximum simultaneous preload links |
| 38 | + maxSimultaneousPreloads: 5, |
| 39 | + // Minimum probability threshold for preloading |
| 40 | + minPreloadProbability: 0.25 |
| 41 | + }, |
| 42 | + }, |
| 43 | + ...opts, |
| 44 | + }); |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +For legacy apps that still need service worker functionality, you can add it back using: |
| 49 | + |
| 50 | +```bash |
| 51 | +npm run qwik add service-worker |
| 52 | +``` |
| 53 | + |
| 54 | +This will add a basic service worker setup that you can customize for specific caching strategies, offline support, or other PWA features beyond just prefetching. |
0 commit comments