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 #products #lamb

January 3 at 2:07 pm

Related posts

  • Wednesday at 11:07 am Navigate Xbox Series console using LG remote
  • February 12 at 10:38 am
  • January 31 at 2:30 pm
  • January 31 at 11:57 am
  • January 23 at 11:21 am
  • January 16 at 4:33 pm
  • January 3 at 2:07 pm
  • January 2 at 4:37 pm
  • December 11 at 8:51 am
  • November 14 at 10:08 am
  • September 22 at 9:12 am On personal goals
  • September 9 at 12:56 pm
  • August 3 at 9:03 am Anchor bugs in Blink engine browsers
  • April 10 at 10:41 am
  • April 6 at 10:43 am
  • March 24 at 7:24 am
  • December 6 at 2:28 pm Lamb image test
  • July 28 at 11:43 am Lamb 0.3.0
  • March 24 at 9:46 am Lamb 0.2
  • March 21 at 12:41 pm Basic routing using REQUEST_URI
  • March 16 at 4:49 pm
  • March 15 at 12:42 pm