Hacker News new | ask | show | jobs
by jazzyjackson 2754 days ago
I'm playing around with an HTML-only page where I want to load lots of resources in iframes, couldn't find much guidance on the web on how bad of an idea this might be (I seem to remember being told each iframe has a similar overhead as a new tab, since it is a whole other browsing context)

Does 25 iframes cause any slowdown? Do you have any tips to keep performance up, like setting display=none to iframes out of view ? I'll test all this soon, I just would appreciate any knowledge you've gained along these lines :)

2 comments

I really haven't researched this topic very much. It was a case of implementing as fast as possible.

Take a look at my repo for how it's implemented; it is not the most responsive site in the world.

What I can tell you is: 1) display=none is a good idea 2) Certain sites have the HTTP header 'X-Frame-Options': BLOCK' or something along those lines. Modern web-browsers wont render those pages in iframes 3) It's a good idea to add sandbox="allow-forms allow-scripts" on every iframe to stop top-level redirects.

I have noticed that it is quite heavy, and my phone's browser handles this for me under-the-hood by saving pages to disk when the iframe is collapsed (I think. I haven't actually tested this but the performance would suggest that this is the case.)

I made a simple page once that loaded about 30 different craigslist iframes of for-sale categories of many regional cities. I never considered performance, but it just worked, and was a huge time saver in terms of the listings I wanted to browse! This was 2010ish, so today I'm not sure how browsers handle this considering CORS.

Edit: to note that I loaded this locally as file://...index.html and you can't publish something like this as an aggregated list due to CLs policies for such use of their content.