Could the preview thumbnails not be a low res or scaled down version of the uncompressed image?
Would help in most cases.
But wouldn't help on that page as still too many far too large images were inlined.
What would help is a "only load images in view". But as you scrolled it would still blow the memory. Additionally this would break jumping to specific comments, as the height of comments above the one you jumped to isn't known and the act of jumping would start loading the images (and scroll the effective jumped to comment downwards as large things load above it).
There's no real solution that produces no edge cases, because it's always possible to inline a third party hosted image that is a 500MB jpg... there would be no way I could know, it would still blow things up.
If I tried to think about measures for things uploaded, then the best I would have is:
- Do not display thumbnails at all, just links to images.
- Reduce maximum file upload size from 30MB back down to 10MB.
- Detect on a per post basis the number of attachments inlined, and limit it to 1 (because there are 25 posts per page, so that still allows 25 images).
- Do not actually inline images... instead just put placeholders. Have JS on the page look at the sum of all placeholders and decide whether to load things (based on assumption of file size).
These things are all a bit crappy.
They prevent native mobile phone uploading of images (bike tag of bike would need post-processing to reduce image size).
They would prevent classifieds from just showing all of the images inline (lots more clicking to see what you're buying).
They would require JS for every page rather than supporting older devices (albeit with more RAM). Arguably login already does this, but I want to undo that and all JS-less browsing to function.
And it is an edge case... we have tens of thousands of classifieds threads with photos inlined, we have bike tag of bike, we have project threads... and this is the first time it has arisen.
That it's so rare an edge case and is going to be solved by time... the upgrade of devices with less RAM, the emergence of SOC CPUs with better RAM capabilities, etc... has me not feeling any urgency or priority to solve it.
It's a single page... it's viewable on desktops (assuming your computer is from the last 20 years)... and the impact to people browsing is very limited. Edge cases happen, but the only question is whether it's acceptable... for me it is, it's an edge case.
In the last 5 years the number of times that has been reported across almost 2B page views is once... that one page. That's well within my bounds of acceptable.