`); // Close the document to finish writing the head and body newWindow.document.close(); // Now you can prepare the content const contentElement = newWindow.document.getElementById('content'); // Function to generate tags function createIElements(count) { const fragment = newWindow.document.createDocumentFragment(); // Create a document fragment for (let i = 0; i < count; i++) { const iElement = newWindow.document.createElement('i'); const randomWeight = Math.floor(Math.random() * 9) * 100 + 100; // Random weight between 100 and 900 iElement.textContent = `Icon ${i + 1}`; // Example text for each tag iElement.style.fontWeight = randomWeight; // Set random font weight fragment.appendChild(iElement); // Append to the fragment } contentElement.appendChild(fragment); // Append the entire fragment to the DOM at once } // Call the function to create a large number of elements createIElements(200000); } // Call the function to test openMemoryEfficientWindow();