简体   繁体   中英

Difference between JavaScript Extensions and NPAPI plugins with respect to performance

I have written a windowless NPAPI plugin which binds to a shared library for accessing my native resources. The plugin is loaded by a web Application running in Firefox browser. Recently, I have seen in net, that using Java Script extensions, one can also make native code function calls.But these Java Script extensions are specific to browsers.

Can some one please tell me that if I use a Java Script extension instead of NPAPI plugin for calling my native code, will there be any performance improvement in terms of latency in making native library API calls?

Kindly note: My query is generic and not specifically for Firefox browser.

There is no generic answer to a question like this, the mechanisms implemented by different browsers have nothing in common.

Firefox : A native library can be called via js-ctypes . This mechanism should be more light-weight than the communication with an NPAPI plugin. Even more importantly, you don't have the overhead of inter-process communication (newer Firefox versions run plugins in separate processes).

Chrome : AFAIK the only way to access operating system functionality (such as writing files to a random location on disk) is via NPAPI, Chrome won't allow extensions to use system libraries. However, if you use a native library only to speed up execution and don't mind having this code run in a sandbox - the native client might work for you. Due to sandboxed execution it will probably be slower than an NPAPI plugin but it won't trigger huge scary warnings when your extension is installed.

Safari : From what I know, Safari doesn't let you use native libraries, not even via NPAPI plugins .

Internet Explorer : As of MSIE 9.0, Internet Explorer still doesn't have anything resembling JavaScript-based extensions.

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