From 578f35dd8ca0da6bfb1df48abe86493258e0c0f2 Mon Sep 17 00:00:00 2001 From: theodorejb Date: Thu, 20 Feb 2020 16:19:27 -0600 Subject: [PATCH] Improve documentation for using the ES6 module and UMD alternative --- site/index.html | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/site/index.html b/site/index.html index 5dba1f5..dbd1380 100644 --- a/site/index.html +++ b/site/index.html @@ -88,8 +88,33 @@

Features

Installation

- Run npm install spin.js (recommended), or save the spin.js file in your repo. + Run npm install spin.js, or save the spin.js and spin.css files in your repository.

+ +

JS bundling

+

+ For best performance and compatibility, it is recommended to use a module bundler such as + Parcel, Rollup, + or Webpack to create a production-ready code bundle. + However, in modern browsers it is also possible to directly load the module via a script tag: +

+
+  <script type="module" src="node_modules/spin.js/spin.js"></script>
+
+

+ If for some reason you can't use ES6 modules or a module bundler, download + spin.umd.js and save it in your repository. + The UMD script can be used as follows: +

+
+  var spinner = new Spin.Spinner(opts).spin(target);
+
+

+ Note that the UMD version is only available as a temporary workaround. + Longer term it is recommended to migrate to the standard ES6 module. +

+ +

CSS

Load the spin.css file to include the default animation presets. You could alternatively create a custom CSS keyframe animation (in your own CSS file) @@ -136,17 +161,6 @@

Usage

element is passed as argument, the spinner is added as first child and horizontally and vertically centered.

-

Bundling

-

- Not all browsers support native ES6 module imports yet, so it is recommended to use a module bundler such as - Webpack or - Rollup to create a production-ready code bundle. -

-

- If for some reason you can't use ES6 modules or a module bundler, download - spin.umd.js and save it in your repo. -

-

Manual insertion

In order to manually insert the spinner into the DOM you can invoke the spin() method