• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

15
Views
Storing and accessing compressed json files from local storage in react native

I have a couple of JSON files used for animation (used in lottie-react-native) in my react native app. Each file is around 100KB and the total size of all JSON files amounts to 2-3MB. Now my goal is to get rid of this 2-3MB as much as possible. So, should I go for cloud storage of these JSON files, or should compress and store them and then later decompress at the time of use? If I should go with the compress/decompress approach, then please suggest the library as well which would perfectly satisfy my requirement.

27 days ago ·

Juan Pablo Isaza

2 answers
Answer question

0

You can use jsonc https://www.npmjs.com/package/jsonc to compress the json files and store them

27 days ago · Juan Pablo Isaza Report

0

Well, you can use Cache Storage for this purpose. (Please check ServiceWorker support on browsers. https://caniuse.com/serviceworkers). It will allow you to load the content once, and cache it in user browser. It is working with ServiceWorker technology, which requires an small implementation.

https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage

Or you can implement google's workbox library, which allows you to do same thing in a cleaner way.

https://developers.google.com/web/tools/workbox/guides/get-started#routing_and_caching_strategies

I can't suggest to put all of your json content to localStorage. It's working memory based. It might have performance problems in low memory/cpu computers.

27 days ago · Juan Pablo Isaza Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.