views:

163

answers:

4

If I built a page that consisted of IFrames on the order of hundreds, would this be incredibly slow, or would it behave similar to having a hundred divs?

The reason I ask is I'm looking for a nice recursive way to build a web page, where I can load sub-elements of a page as if they were complete pages of their own, with their own urls.

Thoughts? Opinions? Am I totally crazy to even be thinking it?

Edit: I just realized this would probably absolutely shred the network connection because it would have to make separate requests for each embedded frame, wouldn't it? And everything I've learned on making web pages more efficient to load is to reduce the number of http requests it needs to make.

+3  A: 

yes, indeed-- browser must make separate requests for each embedded iframe.

Scott Evernden
Ok that takes care of that, then. I'll have to look for another way to do this on the server-side rather than the browser side.
chaiguy
+1  A: 

It will be slightly more efficient than opening hundreds of web browsers, and only slightly. You will still be rendering the pages you load in the iframes and this takes memory.

Andrew Hare
So even if the content of the IFrames were exactly the same as placing the content directly in a div, it would use more memory because it's treating it as an entirely separate page... correct?
chaiguy
yes, a new Window object for each iframe
Itay Moav
Well... not necessarily - are you going to pull the content of the pages via javascript and then put it inside a div? If that is the case then performance differences will probably be negligible. Nothing like a good test to clear that up though L:)
Andrew Hare
Test? What's that? ;)
chaiguy
+2  A: 

This isn't purely related to efficiency, but there are also various gotchas like the Body OnLoad not firing until every single IFrame in the page hierarchy has fully loaded first.

If you need things inside the IFrame javascript to be able to "call out" to another IFrame or the main page this can also cause maintainability and readability problems.

Coxy
Indeed, good point.
chaiguy
A: 

I find difficult to communicate between iframes (in javascript for instance). I prefer divs instead and you can use a server cache where you need it. Maybe a solution which uses partial rendering with Ajax can be more elegant.

labilbe
Yeah I think this is the route I will end up taking.
chaiguy