Installation

Install Attractive.js via pnpm or your package manager of choice.

pnpm

pnpm add attractivejs

npm

npm install attractivejs

Then import it into your JavaScript entrypoint and activate it.

import Attractive from "attractivejs";

Attractive.activate();

CDN

<script type="module">
  import Attractive from "//unpkg.com/attractivejs@1.0.0-alpha.6/dist/attractive.min.js";

  Attractive.activate();
</script>

By default, Attractive observes the entire document. Pass a specific element to scope it:

Attractive.activate({ on: document.getElementById("sidebar") });

Enable debug logging:

Attractive.activate({ debug: true });

Select which actions to enable

Attractive.activate().withActions(["class", "attribute"]);

Only the class and attribute actions will be available. Read also about core if you want to tree-shakeable actions.