Published
Edited
Aug 30, 2021
Insert cell
md`# Local storage test`
Insert cell
md`It's probably best to use the more official https://observablehq.com/@mbostock/safe-local-storage !`
Insert cell
a = button({'value': 'put "foo" in localStorage'})
Insert cell
{
a.onclick = () => localStorage.setItem('value', 'foo')
b.onclick = () => localStorage.setItem('value', undefined)
}
Insert cell
b = button({value: 'clear localStorage'})
Insert cell
md`What's in localStorage?`
Insert cell
localStorage.getItem('value')
Insert cell
manifest = ({
"name": "localStorage test",
"short_name": "lS test",
"description": "A localStorage test.",
"display": "standalone",
"scope": "/",
"icons": []
})
Insert cell
function createWorker(s, cb) {
const worker = new window.Worker(
window.URL.createObjectURL(
new Blob(
[`
self.onmessage = function(e){
let result = eval("("+e.data.script+"())")
self.postMessage(result);
}`
],
{
type: "text/javascript"
}
)
)
);
if (typeof cb == "function") {
cb(worker);
}
}
Insert cell
caches
Insert cell
manifest_url = Files.url(manifest_json)
Insert cell
btoa(manifest_json)
Insert cell
document.head.children[3].outerHTML
Insert cell
window.foo = document.head.appendChild(html`<link rel="manifest" href="${'data:application/json;base64;' + btoa(JSON.stringify(manifest))}">`)
Insert cell
manifest_json = new File([JSON.stringify(manifest)], 'manifest.json')
Insert cell
import {button} from '@jashkenas/inputs'
Insert cell
performance.getEntriesByType("resource")
Insert cell
performance.getEntriesByType("resource").map(e => e.name)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more