Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 422
markzzz Avatar asked May 30 '12 12:05

markzzz


1 Answers

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.

like image 141
VMOrtega Avatar answered Oct 07 '22 14:10

VMOrtega