Netscape Plugin Application Programming Interface (NPAPI) is a deprecated application programming interface (API) for web browser plugins, initially developed for Netscape Navigator 2.0 in 1995 and subsequently adopted by other browsers. In the NPAPI architecture, a plugin declares content types (e.g. "audio/mp3") that it can handle. When the browser encounters a content type it cannot handle natively, it loads the appropriate plugin, sets aside space within the browser context for the plugin to render and then streams data to it. The plugin is responsible for rendering the data. The plugin runs in-place within the page, as opposed to older browsers that had to launch an external application to handle unknown content types. NPAPI requires each plugin to implement and expose approximately 15 functions for initializing, creating, deleting and positioning plugin content. NPAPI also supports scripting, printing, full-screen plugins, windowless plugins and content streaming. NPAPI was frequently used for plugins which required intensive, low-level performance such as video players, including Adobe Flash Player and Microsoft Silverlight, as well as platforms for web applications such as the Java Runtime Environment. NPAPI support among major browsers started to wane since 2015 and it was gradually deprecated over the following 7 years. All major web browsers have removed support for third-party NPAPI plugins for security and maintenance reasons.
History The origin of the Netscape plugin API started not within Netscape, but at Adobe Systems as described in Mattias Andersson's book PDF Printing and Publishing. Adobe CEO John Warnock and Acrobat developer Allan Padgett had been looking for a way to take PDF beyond the desktop, and Netscape's release of Navigator provided that opportunity. Padgett and fellow engineer Eshwar Priyadarshan reverse-engineered the Netscape browser so that PDF files appeared as native web elements, opening inside Navigator when clicked. Their demo was presented to Warnock and Netscape CEO Jim Clark. While Clark was eager to add "Allan's Hack" to Navigator, Padgett proposed an alternative: a plugin architecture such that any file type could be treated as a native format. Adobe engineers Gordon Dow and Nabeel Al-Shamma had recently added a plugin architecture to Acrobat to let third parties extend PDF. Clark agreed and Netscape set off to design an API that would support that model.
Scripting support Scripting is a feature allowing JavaScript code in a web page to interact with the plugin. Various versions of Netscape and then Mozilla supported this feature using different technologies, including LiveConnect, XPConnect, and NPRuntime.
LiveConnect LiveConnect is a feature of Web browsers that allows Java and JavaScript software to intercommunicate within a Web page. The first version of LiveConnect was built by an intern graduate student at Carnegie Mellon University (CMU). From the Java side, it allows an applet to invoke the embedded scripts of a page, or to access the built-in JavaScript environment, much as scripts can. Conversely, from the JavaScript side, it allows a script to invoke applet methods or access Java runtime libraries as much as applets can. LiveConnect was used in Netscape 4 to implement the scriptability of NPAPI plugins. The Open Java Interface-dependent implementation of LiveConnect was removed from the Mozilla source code tree in late June 2009 as part of the Mozilla 2 cleanup effort. It is no longer needed with the release of a redesigned Java Runtime Environment from Sun Microsystems. However, the old implementation was restored for Gecko 1.9.2, as Apple had yet to port the newer JRE over to Mac OS X. The Java–JavaScript functionality supported by the redesigned Java Runtime Environment is still called "LiveConnect", despite the Open Java Interface-specific approach having been abandoned. With Netscape 4, NPAPI was extended to allow plugins to be scripted. This extension is called LiveConnect. A plugin could implement a Java class and expose an instance of it. The class could be called from JavaScript and Java applets running within the page. The disadvantage of LiveConnect is, that it is heavily tied to the version of Java embedded within the Netscape browser. This prevented the browser from using other Java runtimes and added bloat to the browser download size since it required Java to script plugins. Additionally, LiveConnect is tricky to program: The developer has to define a Java class for the plugin, run it through a specialized Java header compiler, and implement native methods. Handling strings, exceptions, and other Java objects from C++ is non-obvious. In addition, LiveConnect uses an earlier and now obsolete application programming interface (API) for invoking native C++ calls from Java, called JRI. The JRI technology has long since been supplanted by JNI.
XPConnect XPConnect (Cross Platform Connect) is a technology which enables simple interoperation between XPCOM and JavaScript.
Object connection XPConnect allows JavaScript objects to transparently access and manipulate XPCOM objects. It also enables JavaScript objects to present XPCOM compliant interfaces to be called by XPCOM objects. A main goal is that objects communicating from either side of an XPCOM style interface should not generally need to know or care about the implementation language of the object on the other side of the interface. XPConnect's primary reason for existence is to replace handwritten code used in places where native code needs to interact with JavaScript code. An example is the DOM module.
… excerpt ends here. Continue reading the full article.