Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How to Build a Persistent 3-Step Checklist Widget in 12 Lines of Vanilla JS (No Frameworks)

Most interactive checklists on the web pull in 150 KB of React state libraries just to toggle three checkboxes. When I built a live countdown & 3-step Cyber Monday cashback tracker for shoppers trying to avoid browser-extension cookie hijacking before Monday, Nov 30 at 11:59 PM PT , I wanted it to persist state across mobile tab reloads in 12 lines of zero-dependency JavaScript . The 12-Line…

Building a persistent three-step checklist widget in 12 lines of vanilla JavaScript is possible without using any frameworks. By leveraging local storage, the widget can retain user progress across multiple tabs and browser sessions.

To create this widget, first insert three checkboxes with a class of "cm-chk" and a data attribute containing a step number (e.g., "s1", "s2", "s3"). Add a div with an id of "cm-prog" to display the current progress.

Next, initialize a JavaScript object called `st` by parsing the value of local storage with a key of "cm90" or defaulting to an empty object. Define a function called `upd` that retrieves all the checkboxes, filters them based on their checked state, and calculates the number of completed steps and the associated monetary value. The progress percentage and monetary value are then updated in the "cm-prog" div.

Attach event listeners to each checkbox, checking the box if its corresponding step is present in the `st` object. When the checkbox's state changes, update the `st` object with the new checked status and store it back in local storage. Finally, call the `upd` function initially to display the initial state.

With this simple yet robust approach, users can seamlessly navigate between cashback portals, retailer checkouts, and even browser extension settings, all while preserving their progress without the need for cookies or additional login walls.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Zero-Backend White-Label Demos: Personalizing Static Sites via URL Query Params in 18 Lines of JS

When pitching coupon bloggers, YouTube deal creators, and Facebook group admins a white-label web hub, the biggest conversion killer is asking them to "imagine" what their branded site would look…

  • Zero-Backend White-Label approach allows instant personalized previews with 18 lines of JS
  • Pre-rendered static HTML pages load in under 3 seconds via Vercel's edge CDN
  • URLSearchParams dynamically update header, title, and CTA based on 'brand' query parameter

How ElevenLabs Handles Emotion and Prosody in Speech

What Makes a Synthetic Voice Feel Human? When you hear a TTS engine say “I’m really excited about this!” and it actually sounds excited, you’ve witnessed the magic of emotion and prosody working…

  • ElevenLabs' tech creates natural-sounding voices with emotion and prosody.
  • Latent diffusion architecture encodes speaker, timbre, emotion, and prosody in shared space.
  • API lets controlling emotion via request payload with strength and prosody through scalar values.

Why 92.9% of Small-Business Websites Miss 3s Mobile LCP (692-Site Lighthouse Dataset)

We analyzed a deduplicated benchmark sample of 692 small-business websites with single-run automated Google Lighthouse mobile audits.

  • 92.9% of small-business websites have slow mobile loading times
  • Median mobile LCP is 8.13 seconds, exceeding Google's 2.5-second recommendation
  • Builder platforms like Squarespace and WordPress have higher mobile LCP times

More from Friday 27 November →