Next.js: Can we implement prefetching not using Service Worker?

Created on 26 Dec 2016  路  3Comments  路  Source: vercel/next.js

First of all, thanks for creating such an amazing tool! Next.js seems like a "dream framework" to me for building web apps, which "brings us the best of both worlds" (single page app and server side rendering).

To me the most important piece that helps Next.js fullfil its promise is the ability to prefetch all the components that the tags point to in a page.

According to the documentation this feature is implemented using Service Worker, a API that only supports Chrome and Firefox. This means a great portion of web users just can't take advantage of this great feature. I don't know if I miss something.

Can we implement prefetching using other kinds of techniques, which support all modern browsers, instead of using Service Worker?

Most helpful comment

A principle that has served us well over the years is to provide _support_ for all browsers, but _optimizations_ for modern ones.

Prefetching is an optimization. To invest more and more code into an optimization that will be deprecated (since all modern user agents support ServiceWorker or plan to do so) doesn't seem like a good area of focus.

If you want, feel free to create your own userland prefetching module that exposes the same API as next/prefetch. The neat thing is: if you don't use next/prefetch, it won't make it into the build. No bloat :)

All 3 comments

This means a great portion of web users just can't take advantage of this great feature

This is kind a untrue. See: http://caniuse.com/#feat=serviceworkers
Browsers are going into this direction and will catch up soon.

Anyway, our current focus is shipping 2.0 and the current prefetching solution is pretty neat for that.
If someone could work on this suggestion, I think we have no reason to say no.
(And it's totally possible to do it in the userland as well)

I noted here some ideas to broaden the support, namely using AppCache: https://github.com/zeit/next.js/issues/24#issuecomment-258804529

A principle that has served us well over the years is to provide _support_ for all browsers, but _optimizations_ for modern ones.

Prefetching is an optimization. To invest more and more code into an optimization that will be deprecated (since all modern user agents support ServiceWorker or plan to do so) doesn't seem like a good area of focus.

If you want, feel free to create your own userland prefetching module that exposes the same API as next/prefetch. The neat thing is: if you don't use next/prefetch, it won't make it into the build. No bloat :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knipferrc picture knipferrc  路  3Comments

pie6k picture pie6k  路  3Comments

wagerfield picture wagerfield  路  3Comments

olifante picture olifante  路  3Comments

flybayer picture flybayer  路  3Comments