In my Ionic framework application, I am dealing with a large amount of data - around 10,000 records initially, with an additional 200 records being added every week. However, the loading time for this information is becoming a concern as certain sections of the app are taking too long to load, resulting in increased CPU and battery usage. Storing the records as .json files results in a file size of approximately 10Mb.
To address this issue, I have been compressing and decompressing the records using the "LZString" library before storing them in localStorage. While this method worked well with 5000 records, I noticed that it was still consuming significant resources due to the use of JSON.parse along with LZString.
My current process involves decompressing the records when needed:
desc = LZString.decompress(window.localStorage.getItem('var')) || []; JSON.parse(desc); // desc contains 5000 records And compressing them again upon first request:
window.localStorage.setItem('var', LZString.compress(JSON.stringify(objJson))); // objJson holds 5000 records Before compression:
Total: 4.82 MB After compression:
Total: 0.55MB I am seeking ways to optimize the performance of my application further and enhance the compression of data. Any suggestions?