You’ll usually see guidance in the documentation of a global library of how to use the library in an HTML script tag:
Today, most popular globally-accessible libraries are actually written as UMD libraries (see below). UMD library documentation is hard to distinguish from global library documentation. Before writing a global declaration file, make sure the library isn’t actually UMD.
or like this:
When looking at the code of a global library, you’ll usually see:
- Top-level
var
statements orfunction
declarations - One or more assignments to
- Assumptions that DOM primitives like
document
orwindow
exist
- CommonJS/Node.js-style imports of the form
var fs = require("fs");
- Calls to
define(...)
- Documentation describing how to
require
or import the library
Because it’s usually easy to turn a global library into a UMD library, very few popular libraries are still written in the global style. However, libraries that are small and require the DOM (or have no dependencies) may still be global.
You can see an example DTS below: