snippets
- introduction
- copy text with selector
- copy text via a selector with messaging
- copy with quick copy
- debounce a signal
- forward an element as a sender
- get random numbers
- load data from a url
- load templates from a url
- map a key to a signal
- match elements from parent
- measure performance
- poll data
- receive multiple signals
- render an svg
- run an init function
- send and receive from the same element
- send multiple signals at the same time
- send to multiple receivers
- shuffle an array
- style SVGs
- switch
- switch with init
- update the content of an element
- use a template from the page
- use an alternate listener
- use innerHTML as a number
measure performance
- The
b.mark()andb.getMarks()methods provide basic timing of named measurements using performance.now() calls.
html
<pre data-r="timeReport"></pre>javascript
export const b = { init: "timeReport" };
export async function timeReport(_, __, el) {
b.mark("snippet");
await b.sleep(100);
b.mark("snippet");
await b.sleep(100);
b.mark("snippet");
el.innerHTML = b.getMarks("snippet")
.map((mark) => mark)
.join("\n");
}