Why bother creating a clean javascript / jquery widget when I can load it into an iframe?

I mean, I use this widget:

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

To check if jquery is on the hosted website otherwise it will load it and execute some ajax / jsonp request. As suggested in this tutorial .

Well, I noticed big trolleybuses about CSS parents, integrated other jquery plugins (like a loop) and managed the data between this β€œinterface” and the ajax call.

Why should I do this when I can use sngle iframe? I also noticed that if I load jquery from widget.js and (of course), I put it in an iframe (so that I can control individual functions), the library is taken from the cache. Therefore, no overload occurs.

Is this enough for you? Or am I missing something?

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

+6
source share
1 answer

The iframe core remains isolated from the rest of the page.

I recommend reading this: iframes vs ajax

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

+5
source

Source: https://habr.com/ru/post/917004/


All Articles