Javascript - Library

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > Javascript - Library

1 - About

library in Javascript.

A library is a distribution format as a package that bundles module.

The difference between a package and a library is that the modules are compiled into one file called a library that is accessible via a single global variable without any sort of import.

Advertising

2.1 - Example

jQuery:

  • The installation of the Jquery library
index.html
<script
  src="https://code.jquery.com/jquery-3.4.1.slim.js"
  integrity="sha256-BTlTdQO9/fascB1drekrDVkaKd9PkwBymMlHOiG+qLI="
  crossorigin="anonymous"></script>
  • jQuery is accessible via the jQuery variable. We select the body element and add a h2 header.
lib.js
jQuery('body').after("<h2>Hello Nico</h2>");

3 - Management

3.1 - Creation

3.2 - Installation

A library is installed via the script element of the html page. The library will be then available via a global variable

As a library is another format distribution of a package. If you are working in a project developed locally with the node engine, you may also want to install it as a package via a package manager)

Advertising

3.3 - List

Every package may takes the form of a library

Example:

  • AngularJs
  • Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
  • The Dojo Toolkit is a modular open source JavaScript toolkit (or library), designed to ease the rapid development of cross platform, JavaScript/Ajax based applications and web sites

3.4 - Popularity

4 - Documentation / Reference