简体   繁体   中英

Javascript only Iframes

I am making a nw.js application that I want to be able to be modded. However, for ease of use I want to allow all the mods to have their own separate sets of global variables, yet I still need to access all the variables and classes from the main application. My original idea was to use iframes, which would probably work. However, iframes are slow and are just simply messy code. Is there any better way to do this, or am I just stuck using iframes?

Would creating a global object that represents the namespace for your module suffice?

var myNamespace = myNamespace || {};

It would be impossible to have two global namespaces within the same window as all global properties are properties of the window.

I think the require function is the way to go. I got the idea while reading Brian's answer, so I thank Brian.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM