ArticleslgStudy

computer science

NPAPI

NPAPI is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand NPAPI rather than just read about it. In short: 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.

Key takeaways

  • NPAPI belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect NPAPI to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of NPAPI from memory before moving on to harder problems.

Reference excerpt

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.

Worked examples

Example 1 — a first encounter with NPAPI

Start with the simplest possible case. Write down what NPAPI claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to NPAPI before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about NPAPI ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of NPAPI

In research
NPAPI appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses NPAPI in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
NPAPI is common in secondary-school and first-year university syllabi. It links to neighbouring topics Application programming interfaces, Software add-ons, Web browsers, so understanding it makes those chapters shorter.
In everyday life
Look for NPAPI outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “NPAPI” →

How to study NPAPI in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what NPAPI means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain NPAPI out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is NPAPI in simple terms?

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…

Why does NPAPI matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study NPAPI?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on NPAPI.

Tags

  • Application programming interfaces
  • Software add-ons
  • Web browsers

Keep exploring