0

I followed this code to let user download files to cache to display them offline: https://serviceworke.rs/cache-from-zip.html

It works, but with large files it can take some time so I would like to show a progress indicator while loading the zip file.

I guess it's in the fetch part that it could be done but I don't know how: https://serviceworke.rs/cache-from-zip_worker_doc.html

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
jeromebg
  • 19
  • 1
  • 6

2 Answers2

0

Declare a let or var variable which is null initially. Then during data fetch assign the response to that variable.

Use an if-else statement to display a spinner while said variable is null.

Eric
  • 940
  • 12
  • 27
0

Upload progress indicators for fetch?

Have a look here, the second answer in particular might be of help to your problem.

EDIT: I am assuming you can derive similar information regardless of up or download - unfortunately not sure.

Stefan Januschke
  • 322
  • 4
  • 20
  • 1
    thanx @Stefan Januschke, unfortunatly my javascript skills are close to none ;) I found this one but don't find how to implement it to the existing code I use : https://github.com/AnthumChris/fetch-progress-indicators – jeromebg Jun 15 '20 at 18:49
  • Look into the second code example provided in the referenced article. I would recommend to simply copy paste the code and try to apply it to your code. In the midterm you will run in to more problems with your page where you will need some JS knowledge, this might be a good point to acquire some of the knowledge when working with API's you probably need to successfully finish your project. I know a "Just do this" answer would be what you wish for right now, but not working on your code this is close to impossible. Try your best and learn a lot on the way! – Stefan Januschke Jun 15 '20 at 19:14
  • 1
    You're right @Stefan , and it was easier than I thought ! THX – jeromebg Jun 16 '20 at 09:39