bitty installation snippets examples documentation q&a

installation

the steps

  1. Adding bitty to a page is done by including it via a script tag. Start by downloading it:

    bitty-8.0.0.js

  2. Put the file on your server. Then, call it from your pages with:

    <script type="module" src="/path/to/bitty-8.0.0.js"></script>
  3. Once the script tag is on your page. Create a JavaScript module file with your features and connect to it with a bitty tag like:

    <bitty-8 data-connect="/path/to/module.js"></bitty-8>

hello, bitty

You can use these two files for a complete example to get you started (the only thing you'll need to do is adjust the paths to point to your actual file locations).

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      body { background-color: #222; color: #eef2f2; }
    </style>
  </head>
  <body>
    <bitty-8 data-connect="/versions/8/0/0/installation/example-bit.js"></bitty-8>

    <div data-r="hello">---</div>
    <button data-s="hello">say hello</button>

    <script type="module" src="/v/8.0.0/bitty-8.0.0.js"></script>
  </body>
</html>

example-bit.js

export const b = {};

export function hello(_, __, el) {
  el.innerHTML = "hello, bitty!";
}

using bitty with other software

bitty is designed to play nice with other software. As long as the framework/app/whatever doesn't interfere with loading scripts on a page or calling modules, bitty will work just fine.