Quick use
If you just want to play around ASAP, the quickest way is to import the entire library, either as a module in your JS:
import Color from "https://colorjs.io/dist/color.js";
To be able to use import
statements in your JS, your <script>
element needs type="module"
Color
as a global variable, the classic way, just include the following script in your HTML:
<script src="https://colorjs.io/dist/color.global.js"></script>
You can also add .min
right before the .js
extension to get a minified file.
You can also import individual functions and use the tree-shakeable API.
To use with older browsers (e.g. Opera v89) or platforms (e.g. Node.js v12 or v14), add.legacy
right before the .js
extension to get a transpiled version:
const Color = require("colorjs.io/dist/color.legacy.cjs").default
<script src="https://colorjs.io/dist/color.global.legacy.js"></script>
Via npm
Run:
npm install colorjs.io
Custom bundle
Custom bundle generator coming soon! Until then, you can import individual modules yourself, either from https://colorjs.io/src/
or your local node_modules/colorjs.io
if using npm.