Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Optimising large string on browser on load time

I have created a function which will dynamically append xml content to a string variable on browser on load time . However, when the string becomes enormous , it will result in memory loss. I have created a function which enable user to download as xls format.

For an example,

//This has 1k records which are translated as xml content that is stored in uri variable on browser. We are able to download xls file with no issue

//String length e.g 20k
var workbookXML = 'data:application/vnd.ms-excel;base64,.......<?xml version="1.0"?><?mso-.application progid="Excel.Sheet"?>.........'

now when im appending high volume of data that are translated into xml content , this will result the browser to stop and prompt Memory loss issue on browser

//String length e.g 20million
var workbookXML = 'data:application/vnd.ms-excel;base64,.......<?xml version="1.0"?><?mso-.application progid="Excel.Sheet"?>.........'

I have look into writableStream but this will result the same as this will be on browser. . What are best approaches in this use cases to resolve big data into a single string variable on browser?

Should i convert string into binary, bytes before exporting as xls format ?

        var excel_blob = new Blob([workbookXML], { type: 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
        var link = document.createElement("A");
        link.href = window.webkitURL.createObjectURL(excel_blob)
        link.download = "BigData" + ".xls";
        link.target = '_blank';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What are best approaches in this use cases to resolve big data into a single string variable on browser?

Simple: don't.

It looks like you're trying to download files? There already is a tried and true protocol to download files, which is using a get request to get back a file (or multiple files, if your browser supports it).

There's absolutely no need to store the entire file in html in a base64 string, append it to your DOM as an element, click it to initiate the download and remove it. That's just insanity.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!