Workers of js-ipfs on the browser

I’ve heard on the IRC chan that js-ipfs relies on the Workers API to run on the browser. But what type of Workers?

  • If it’s Service Workers, it would allow to keep the IPFS daemon running when you change pages. But the downside is that you need to be in HTTPS to use Service Workers, so you have to buy a TLS certificate to use js-ipfs on your website. Besides, the ipfs-js daemon would be killed as soon as you leave the website.
  • If it’s Web Workers we don’t need TLS certificates anymore but in this case we can’t keep js-ipfs running between 2 pages.

So the real question is: how does IPFS Companion manages to keep the same js-ipfs daemon wherever you go?

Hi @talb
js-ipfs does not rely on any Workers API, it can however, run inside a WebWorker or a Service Worker. The advantage of running it inside a Worker is that IPFS can do its thing without taking resources from the main thread where your Application runs.

Find demos on how to use it at:

Hi @daviddias, thank you for your help. How does IPFS Companion manages to keep IPFS running when changing pages, i.e. where does it run the code? And is it possible to keep a js-ipfs node running (without IPFS Companion) when changing pages in a website?