Every time I load everything at once I get thousands of objects and chrome crashes.
btn.addEventListener('click', function(){ event.preventDefault(); async function getData(){ const response=await fetch(url) const data= await response.json(); info(data) } getData(); function info(x){ x.messages.forEach(element => { console.log(element.creator.name+": "+element.text) // console.log(x.element.text) con.innerHTML += "<p>"+element.creator.name+": "+element.text+"</p>"; }); }
This is my code using rn
The first innerhtml is very slow because it needs to be parsed every time. Create a function to create a Dom element and attach it to the desired container. Adding pagination or processes to insert data in chunks would also help.
Try to use appending child elements to load one element at a time. I've left an alternative code here.
sandbox
Code