What would it take to make writing vanilla JavaScript more pleasant? After reviewing the code for my blogging engine Lamb I concluded:

Most of the code adding interactivity to personal websites comes down to running code after the page has loaded; niceties to query the DOM and hook into events. There's probably more but this is a start. The result is shorthand.js. Hint: it's not dissimilar to jQuery, but you can fully learn it in 5 minutes.

Which simplifies code to:

onLoaded(() => {
    const forms = $$('form.form-delete')
    forms?.forEach($form => $form.on('submit', ev => {
        cancel(ev)
        let confirmed = confirm(`Really delete status ${ev.target.dataset.id}?`)
        if (!confirmed) return
        ev.target.submit()
    }))
})

This is just a prototype and will evolve.

#technology #projects #lamb

January 3 at 2:07 pm

Related posts

  • September 4 at 8:38 am We need more instant publishing on the web…
  • June 24 at 1:50 pm Found an interesting article with a positi…
  • February 21 at 11:07 am Navigate Xbox Series console using LG remo…
  • February 12 at 10:38 am Looking at my browser tabs, I can't believ…
  • January 31 at 2:30 pm Content vs crap. #technology…
  • January 31 at 11:57 am Use an expression to select an array value…
  • January 23 at 11:21 am Why do web-browsers not have a dedicated &…
  • January 16 at 4:33 pm Finally updated my #WordPress Blocks In Pl…
  • January 3 at 2:07 pm What would it take to make writing vanilla…
  • January 2 at 4:37 pm If you're using the Anytype (current versi…
  • December 11 at 8:51 am I experimented with _hyperscript to replac…
  • November 14 at 10:08 am Ashley Belanger writes for Ars Technica Ap…
  • September 22, 2023 at 9:12 am On personal goals…
  • September 9, 2023 at 12:56 pm If you want an example of why we need a vi…
  • August 3, 2023 at 9:03 am Anchor bugs in Blink engine browsers…
  • April 10, 2023 at 10:41 am The AI evolution seems scary until you rea…
  • April 6, 2023 at 10:43 am Ubuntu's minimal installation appears to b…
  • March 24, 2023 at 7:24 am Anyone, regardless of coding experience ca…
  • September 27 at 9:39 am Taskfile EOL…
  • September 5 at 10:51 am If you're looking for a script to get…
  • September 4 at 8:40 am There is no barrier when there is no UI fr…
  • September 4 at 8:39 am By the time you're logged into your C…
  • August 6 at 8:23 am Taskfile 2.0.0…
  • July 16 at 10:38 am I've archived my php-activate project…
  • June 12 at 4:11 pm Trying out a new 2024 theme I've star…
  • January 16 at 10:16 am Created a HTMX PHP sandbox to get started …
  • January 10 at 9:07 am I've updated my one stop system update scr…
  • January 2 at 9:59 am PHP-Activate 0.3.1…
  • December 15 at 9:47 am PHP-Activate 0.3.0…
  • December 6 at 2:28 pm Lamb image test…
  • October 5, 2023 at 8:59 am PHP-Activate 0.2.0…
  • September 19, 2023 at 1:52 pm Made a Linux shell script called BreakAwar…
  • July 28, 2023 at 11:43 am Lamb 0.3.0…
  • June 17, 2023 at 7:33 pm Fafi 0.2.3…
  • March 24, 2023 at 9:46 am Lamb 0.2…
  • March 21, 2023 at 2:28 pm I've released php-activate 0.1.2, a PHP pr…
  • March 16, 2023 at 4:49 pm 404 Fallback comes to Lamb I've added a 40…
  • March 15, 2023 at 12:42 pm Alright got the webserver configuration fi…
  • September 27 at 9:37 am I switched back to the vintage theme as th…
  • March 21, 2023 at 12:41 pm Basic routing using REQUEST_URI…