Global Libraries

Global Libraries

A global library is one that can be accessed from the global scope (i.e. without using any form of import). Many libraries simply expose one or more global variables for use. For example, if you were using jQuery, the $ variable can be used by simply referring to it:

$(() => { console.log('hello!'); } );

You’ll usually see guidance in the documentation of a global library of how to use the library in an HTML script tag:

<script src="http://a.great.cdn.for/someLib.js"></script>

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.

doc_TypeScript
2016-10-04 19:25:15
Comments
Leave a Comment

Please login to continue.