When to use iframes or partial views?

Hi All,

I’m trying to work out the best way to implement a page with various
sections.

One section reports statistics about players in a team, the user selects
from a row of player icons, and underneath this, a set of graphs are
displayed.

One way I thought of doing this was to have the ‘graph view’ as an
iframe, and when the user clicks on the player icon, a new url is loaded
in the iframe eg root/graphs_controller/graph_for_player/13.

I already have an iFrame for a google maps view also on the page.

Are there any considerations when using iframes? Can they slow the
loading time?

Another way to do this would be to use Ajax to reload a partial view on
the page.

Would this be quicker / slower?

Any experience / advice on the matter would be appreciated!

Bump?

Michael B. wrote in post #1061633:

I’m trying to work out the best way to implement a page with various
sections.

One section reports statistics about players in a team, the user selects
from a row of player icons, and underneath this, a set of graphs are
displayed.

One way I thought of doing this was to have the ‘graph view’ as an
iframe, and when the user clicks on the player icon, a new url is loaded
in the iframe eg root/graphs_controller/graph_for_player/13.

In general, frames/iframes are evil!

I already have an iFrame for a google maps view also on the page.

But, sometimes a necessary evil.

Are there any considerations when using iframes? Can they slow the
loading time?

Technically yes they can. Is it likely to matter? Probably not. Loading
a page with an iframe is effectively the same as loading two separate
pages. There’s two requests to the server. The content of the iframe
includes markup not necessary when compared with an AJAX partial page
download.

Another way to do this would be to use Ajax to reload a partial view on
the page.

This would almost certainly be the choice I would make myself.

Would this be quicker / slower?

What do you mean by quicker, performance or development time? If the
former see above, if the latter, well that depends on how skilled you
are with JavaScript and AJAX.

Any experience / advice on the matter would be appreciated!

AJAX provides a far superior user experience in my view. The current
trend is to build web applications that behave more like desktop
applications, and the web is getting better for it IMHO.

iframes are not always evil, but framesets are. Well, ok, framesets may
not be “evil,” per se, but they are 13-year old web development (I
personally haven’t visited a site with a frameset since 1999).

It sounds just based exclusively on your questions you want to use ajax.
Updating part of the page after an action happens is a job for Ajax, not
iframes.

There are good cases to use iframes (like a Google map embedded on your
page, or some piece of your page that you want to call an external
service for), but calling external services absolutely creates more
points of failure.

What you want is Ajax. While you’re at it, take a look into Backbone JS,
Spine JS, and Ember JS. Based on your questions those might be overkill,
but at least learn what’s out there if you’re going down this path. (For
one little page with one little piece of Ajax, those JS frameworks are
overkill. If you are writing a sophisticated client-side app that
demands great in-page updating and instantaneous re-display of
information, you’d be crazy not to use a JS framework like those
mentioned)

-Jason