1

Is it possible to isolate parts of a page, so that each part can use a different javascript framework (or version).

For eample

<div id="content1">
    Uses angular 1.5/jquery 1.x/etc
</div>
<div id="content2">
    Uses angular 2/jquery 2.x/etc 
</div>
<div id="content3">
    Uses react/jquery 2/etc
</div>

Is it possible to isolate each snippet such that they don't interfere with each other regardless of what framework they use?

Obviously i could use iframes, but is there another solution?

tom
  • 694
  • 4
  • 10
  • It's possible with sandboxing techniques, yes, but there's hardly a good reason to do this. – Bergi Apr 17 '16 at 13:45
  • What sandboxing techniques exist? I know you can do it with iframes. What others exist? – tom Apr 18 '16 at 21:24
  • Apart from the `noconflict` methods of the libs themselves, have a look at Google Caja – Bergi Apr 18 '16 at 21:45

2 Answers2

1

its somehow feasible but its hard to maintain and you have to handle that yourself, not HTML will choose the lib version according to which element,

for example:

  • jQuery: you can use jQuery noconflict to load multiple jQuery version in same page,

  • Angular: check this answer for Multiple versions of AngularJS in one page

  • React: its different framework than angular so both can work side by side and you can handle which framework to work with each part in the page.

Community
  • 1
  • 1
mohamed-ibrahim
  • 10,837
  • 4
  • 39
  • 51
0

No. The JS environment is "the window/frame", you can't narrow it further than that.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335