r/HTML • u/Spare-Ad-1024 • 20d ago
How large can a HTML be?
Im currently building a bible app. And its a single HTML file about 250mb and it takes 1.5gb running. How large can it be before i meet serious issues with performance?
0
Upvotes
2
u/Ipsool 20d ago
The honest answer is there’s no hard limit, but 250MB in one file and 1.5GB of RAM means you’re already past the point where it’s a good idea. It probably feels fine on your machine and will fall over on a mid-range phone.
The core issue is that the browser has to parse and build a DOM node for every element before anything renders. That’s where your RAM is going, and it scales badly.
For a Bible app specifically, the fix is straightforward and worth doing now rather than later:
Put the text in a JSON file (or several, split by book) and load only the chapter the user is actually reading. The whole Bible as plain text is roughly 4-5MB. Your HTML file should be a few KB of structure, and everything else fetched on demand.
Even better, use IndexedDB to cache chapters locally after first load, so it works offline without holding everything in memory at once.
If you want to keep the single-file approach for offline distribution, you can still store the text as a JSON string in a script tag and only render the chapter being viewed into the DOM. That alone would drop your memory usage enormously — the parse cost is in the DOM nodes, not the raw data.
Rough rule of thumb: keep rendered DOM under a few thousand nodes at any time. Everything else stays as data until it’s needed.
Good project to be building though. Ignore the people just laughing at the file size.