markzzz
markzzz

Reputation: 47965

Why worry about make a pure javascript/jquery widget when I can load it into an iframe?

I mean, I use to have this widget :

<script src="http://www.mywebsite.com/widget/widget.js?type=normal" type="text/javascript"></script>
<div id="archie-container"></div>

that check if jquery is on the hosted website; else it load it and do some ajax/jsonp request. As suggested by this tutorial.

Well, I've noticed big trobules about CSS parents, integrate other jquery plugins (like cycle) and manage data between this "interface" and the ajax call.

Why I should do it when I can use a sngle iframe? I also noticed that, if I load jquery from widget.js, and (of course) i put it into the iframe (so I can manage separate functions) the library are taken from cache. So there isn't any overload.

Is it good enough for you this approch? Or I am missing somethings?

I also noticed that 90% of widgets (like FB, twitter, etc) use this strategy (with iframe).

Upvotes: 6

Views: 587

Answers (1)

VMOrtega
VMOrtega

Reputation: 1978

An iframe keeps isolated from the rest of the page.

I recomend read this: iframes vs ajax

if something isolated from the rest of the page, and simple go with iframe. If the widget interacts with the rest of the page go AJAX.

Upvotes: 5

Related Questions