questions and answers
What is bitty's goal?
To make it easier to make things on the web.
What's the main idea?
Common things should be easy, uncommon things should be possible.
This is Lea Verou's quote paraphrasing Alan Key's "Simple things should be easy, complex things should be possible."
What approaches support the goal?
- Use native HTML and JavaScript.
- Don't require dependencies.
- Don't require build tools.
Why no JSX?
JSX increases the barrier to entry for getting started. You have to pick up a third thing beyond HTML and JavaScript.
Sure, there are a few things you have to learn about bitty to use it, but they are all vanilla JS.
What about progressive enhancement?
bitty was designed specifically to support progressive enhancement. That's part of the reason it relies on native HTML and JavaScript. You can have 100% of your content in HTML with bitty only providing nice-to-have features.
Of course, you can also start
with nothing but a single <div>
on the page and build everything
with bitty too.
Why put templates in script tags instead of template tags?
Two reasons:
-
<template>tags get parsed as HTML when they are ingested.This means trying to do something like this won't work:
<img IMG_SRC alt="ALT_TEXT" />Depending on the browser the
SRCstring gets turned intoimg_src=""which breaks the find/replace functionality. -
Browsers may try to load
<img>tags found inside templates. Doing something like this causes 404 errors as a result:<img src="IMG_SRC" alt="ALT_TEXT" />
Using the <script> tags eliminates those issues.
The content is simply
treated as a block of data
with no further processing by the browser.
How fast is bitty?
bitty's primary functionality breaks down to:
- Listening for events to trigger signals.
- Using query selectors find elements that receive a given signal.
bitty's performance is based largely on how well browsers are optimized for those functions.
To provide a concrete number, here's an example:
- Renders 1,000 text/button pairs from a template where each render contains both a sender and a receiver.
- Clicks a button to determine how long it takes to process a signal across all the items.
Benchmark code
Run Benchmark
waiting
_
ping
Time to create elements: __CREATE__
Time to process signal: __BENCH__
;
let count = 1000;