Jay Huang
Jay Huang

Reputation: 119

How to compare IFrame and Ajax contents in terms of performance and memory usage?

I have a page that contains a big chunk of contents generated dynamically by the server in the same domain & web app, I have total control of the page and the generation of the contents. So I have 2 options here :

  1. use IFrame to load the contents and change src attribute when contents refresh.

  2. Ajax

Please note that the contents could be refreshed & changed to other contents, that means the iframe's src could be dynamically changed or the ajax contents could be refreshed frequently depending on the user.

Providing that I will clean up the iframe's/Ajax's resources(html, javascript objects,event listeners, etc) before unload/refresh, which option is preferable in terms of performance and memory usage if the contents are refreshed frequently? And what I should keep an eye on when doing frequent contents refresh?

Thank you.

Upvotes: 2

Views: 237

Answers (1)

Joseph Adams
Joseph Adams

Reputation: 982

If I were you I would go for AJAX, for a number of reasons:

  • It is cleaner to work with
  • You wouldn't have to deal with extracting the content and manipulating the DOM, which is always slow
  • It is easier to debug

Generally, I would say a good rule is: Don't use anything it wasn't made for on a large scale

Upvotes: 1

Related Questions