Are there any performance differences when I would load up a formatted element through an iframe or via an ajax call retrieving json data and let javascript put it in a html design? I tend to look at how major websites are doing it and i noticed that ebay uses a lot of iframes. On the homepage there are like four iframes, one of them is obvious though since it’s an advertisement.
Also, within an iframe i can’t access the parent’s javascript files although it’s on the same domain, so within the iframe i have to load the .js file again. I wonder whether this is a technical issue or safety precaution in terms of XSS which is still weird because it’s on the same domain… An example is the jquery .js distribution file, I have to load this in both the parent and the iframe. Would browsers use the parent’s cached version of this or download the whole .js file again?
This is actually a number of questions.
First I’ll address overall speed:
Short answer: it depends. There are a number of factors here.
Ajax method – probably faster to load the data from the server, slower to display client-side.
IFrame method – probably slower to load from server, faster to display client side.
I would think the trend towards using iframes for ads is more to do with security concerns and overall design requirements.
Within the iframe, if it loaded from the same domain as the parent, you should be able to do
parent.$orparent.jQuery. See this question.Caching introduces a whole extra layer into this. Caching will probably happen, though it really depends on browser settings or proxy settings even.