Web Tools #504 - AbortController, Frameworks, Build Tools, JS Utils

Web Tools Weekly
WEB VERSION
Tools for Web Developers

Issue #504 • March 16, 2023

Advertisement

CodiumAI. Generating Meaningful Tests for Busy Devs.
With CodiumAI, you get non-trivial tests (and trivial, too!) suggested right inside your IDE, so you can code smart, create more value, and stay confident when you push.

CodiumAI

By analyzing your code, docstring, and comments, and by interacting with you, TestGPT (by CodiumAI) suggests tests as you code. All you have to do is accept and commit them.

Try Now For Free!

Let's take a quick look at the AbortController API, a relatively new feature in the DOM spec that allows you to cancel asynchronous tasks that are in progress. The main parts of the API are the AbortController() constructor, the signal property, and the abort() method.

I can mimic an asynchronous action by simply creating a Promise that resolves after a set timer. The basic framework of code for this might look something like the following:

// Create the controller
const controller = new AbortController(),
      signal = controller.signal;

const promise = new Promise((resolve, reject) => {
  // Start async action
  const timer = setTimeout(() => {
    resolve('Timer has completed!');
  }, 5000);

  // Listen for abort
  signal.addEventListener('abort', () => {
    clearTimeout(timer);
    // Result if aborted
    console.log("Timer was aborted!");
  });
});

// Result if not aborted
promise.then(result => console.log(result));

// Abort it
controller.abort();

To make it easier to understand, the above code is somewhat brief, so it's not very practical. For example, the controller is immediately aborted but that's not normally what you'd want.

A more realistic example can be found in this CodePen demo. There I'm allowing the user to initiate the timer using a button. Then the timer can be stopped (i.e. the controller is aborted) with another button. This mimics what might take place dynamically in the process of a real app. In the demo, if you abort the timer, you'll have to refresh the page to reset it because a Promise cannot be reset once it's resolved.

The AbortController API can be incorporated in a number of practical ways in order to stop certain actions on the page from continuing, maybe for performance reasons or something else. Some examples:

  • Cancel a network request when the user navigates away from a page.
  • Disable animations when the user scrolls so that that animated portion of the page is no longer visible.
  • Large resources on a page (like images or videos) can be cancelled if they are still in the process of loading but aren't needed anymore. MDN's article on the subject includes a live demo with a cancellable video.
I'm sure you can come up with other examples along the same lines, but you get the gist of its use and how it might come in handy to make pages perform better and provide a better overall experience.

Now on to this week's tools!
 

Web Frameworks

Kobalte
A UI toolkit for building accessible web apps and design systems with SolidJS that provides a set of low-level UI components and primitives that can be the foundation for your design system implementation.

NextBase Lite
A simple but very opinionated Next.js 13 + Supabase boilerplate, built with TypeScript, Tailwind, ESLint, Prettier, Husky, React Query, and much more.

Camome UI
A lightweight and accessible UI framework for React and CSS that enables you to build various styles of components without run-time JavaScript by fully utilizing the power of CSS.

CodiumAI. Generating Meaningful Tests for Busy Devs.
With CodiumAI, you get non-trivial tests (and trivial, too!) suggested right inside your IDE, so you can code smart, create more value, and stay confident when you push. By analyzing your code, docstring, and comments, and by interacting with you, TestGPT (by CodiumAI) suggests tests as you code. All you have to do is accept and commit them.   SPONSORED  

DecaUI
A large suite of React components that are themeable, accessible, include built-in dark mode, and built with Stitches, the CSS-in-JS solution.

React Pro Boilerplate
A React and Next.js boilerplate that also includes TypeScript support, Prettier, and ESLint.

Flowbite-Svelte
An official Flowbite component library for Svelte that includes 30+ components, form controls, typography features, and more.

Flowbite-Svelte

AstroWind
An open-source template for building projects with Astro 2.0 and Tailwind featuring production-ready Lighthouse scores and SEO-ready content and image optimization, and lots more.

Practica.js
Generate a Node.js app that's packed with best practices and simplicity, based on the popular Node.js Best Practices GitHub repo.

Tiny Vue 3 Template
A small template for building Vue projects with no build step, but instead using Vue through a CDN.

shadcn/ui
30+ beautifully designed components, built with Radix UI and Tailwind, that are accessible and customizable and can be used to create your own component library.
 

Build Tools, Bundlers, etc.

Bob
A high-level build tool for microservices, for multi-language projects, to build codebases organized in multiple repositories or in a monorepo.

stale-dep
A CLI tool to check if your node_modules folder is stale compared to the last time you checked.

Typewind
A Babel-based build solution that brings the safety, productivity, and IntelliSense of TypeScript to Tailwind projects with zero bundle size.

Don’t Just Read The News—Make The News
Looking for an edge in business? Look no further than The Information. Their team of award-winning journalists provide exclusive insights into tech and finance, with original reporting, big interviews, and more that you won’t find anywhere else. Subscribe now and save 25%.   SPONSORED  

pacote
An npm fetcher that fetches package manifests and tarballs from the npm registry.

vite-plugin-checker
A Vite plugin that adds Worker-based checks for TypeScript, ESLint, vue-tsc, Stylelint and more.

depngn
Short for "dependency engine", a CLI tool to find out if your dependencies support a given version of Node.

Remix Compute
A Remix adapter and server runtime for Netlify that allows you to deploy your Remix apps to Netlify Edge Functions.

publint
An online tool that lints npm packages for packaging errors, ensuring maximum compatibility across environments (e.g. Vite, Webpack, Rollup, Node.js, etc).

publint

genzo
A Node-based CLI tool to scaffold your projects for development with custom templates from GitHub or your local file system.

vite-plugin-react-swc
A plugin for Vite that enables SWC (the Rust-based build tool) on your dev server with faster refresh and automatic JSX runtime enabled.

Scriptful
An enhancement for package.json scripts that allows you to run multiple scripts at once and reuse them.
 

JavaScript Utilities

Constrain
A library for animated, interactive web figures (e.g. interactive pythagorean theorem, computing the golden ratio, etc.) based on declarative constraint solving.

MiniSearch
A tiny but powerful in-memory full-text search engine written that's respectful of resources and can comfortably run both in Node and the browser.

ScrollyVideo.js
Responsive scrollable videos without obscure video encoding requirements, compatible with React, Svelte, Vue, and plain HTML/JS.

validator.js
A library of string validators and sanitizers that includes about 100 different utilities (e.g isCreditCard, isCurrency, isEmpty, isISBN, and lots more).

Don’t Just Read The News—Make The News
Looking for an edge in business? Look no further than The Information. Their team of award-winning journalists provide exclusive insights into tech and finance, with original reporting, big interviews, and more that you won’t find anywhere else. Subscribe now and save 25%.   SPONSORED  

Lenis
A lightweight smooth effects-on-scroll plugin that's accessible and incorporates features for CSS sticky and IntersectionObserver.

BoxSlider
A small dependency-free library that provides a lightweight, responsive content slider with various slide transition effects for modern browsers. The demo page is pretty impressive!

BoxSlider

html2svg
Convert HTML and Canvas to vector (SVG, PDF) or bitmap (PNG, JPEG, WebP) images using Chromium.

URL Animations
A small library to add loading animations to a website in the browser's address bar. Not for every project, but includes a gallery of examples to check out.

BalanceText
A utility to provide an alternate text wrapping algorithm to ensure that text is rendered so that the amount of text on each line is about the same.

Idiomorph
A JavaScript library for morphing one DOM tree into another, inspired by a couple of other older similar solutions.

Authey
Expose Auth.js REST APIs to any Node.js framework compatible with Connect, the Node.js middleware layer.

Commercial Apps and Classifieds

These are commercial apps, affiliate links, PPC ads, and paid classifieds. Submit yours!
Internal – An all-in-one internal tools platform with database, API, or Google Sheets integration.
JS E-Books Bundle – All my JS and DOM scripting tips bundled into an affordable e-books package.    AD
Browserbear – Easily automate any browser task like testing websites, capturing data and more
Stellate – A fast and reliable GraphQL API with edge caching, metrics, and rate limiting, to help reduce server and database load.
Tech Brew – A 3-times-a-week newsletter with the latest tech news impacting you and your future. AD
JamComments – A Disqus alternative for static sites that's SEO-friendly and ad-free.
Squash – A batch photo editor for Mac to quickly batch convert and resize images, add watermarks, etc.

A Tweet for Thought

Here's a short but informative Tweet thread from Todd Motto where he offers a few lessons on understanding certain concepts in JavaScript.
 
A Tweet for Thought
 

Send Me Your Tools!

Made something? Send links via Direct Message on Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions for improvement or corrections, feel free to reply to this email.
 

Before I Go...

Someone decided to make FlappyBirdle, the most frustrating game in the history of everything. I'm so angry I can't even talk right now.

Thanks to everyone for subscribing and reading!

Keep tooling,
Louis
@WebToolsWeekly
PayPal.me/WebToolsWeekly

Key phrases

Older messages

Web Tools #503 - Factory Pattern, CSS Tools, Git/CLI, Uncats

Thursday, March 9, 2023

Web Tools Weekly WEB VERSION Issue #503 • March 9, 2023 Advertisement Sharpen your Math, Data, and Computer Science Skills Whether you're a professional looking for an edge in your career or a

Web Tools #502 - Promises, Media/SVG, Build Tools, React

Thursday, March 2, 2023

Web Tools Weekly WEB VERSION Issue #502 • March 2, 2023 Advertisement Sharpen your Math, Data, and Computer Science Skills Whether you're a professional looking for an edge in your career or a

Web Tools #501 - FontFaceSet, JS Libraries, Databases, Jamstack

Thursday, February 23, 2023

Web Tools Weekly WEB VERSION Issue #501 • February 23, 2023 Advertisement Build Internal Tools, Remarkably Fast If you or your team are spending more time on boilerplate code and other redundant work

Web Tools #500 - assert(), Frameworks, JS Utils, Uncats

Friday, February 17, 2023

Web Tools Weekly WEB VERSION Issue #500 • February 16, 2023 Advertisement The New Tab Page You'll Actually Use Ah, the hyperlink. It's the single coolest thing on the web. There wouldn't

Web Tools #499 - JS Libraries, Git/CLI Tools, React

Thursday, February 9, 2023

Web Tools Weekly WEB VERSION Issue #499 • February 9, 2023 Advertisement Practical, No-nonsense UI Design Tips 🔥 If you do any design work, you might struggle to find actually practical UI advice that

Warning: Crypto-Stealing Malware Hiding in TOR Browser Installers

Wednesday, March 29, 2023

The Hacker News Daily Updates Newsletter cover THN Webinar: 3 Research-Backed Ways to Secure Your Identity Perimeter Don't Let Cybercriminals Sneak in Through the Identity Perimeter: Get Actionable

Here's how 'Legend of Zelda: Tears of the Kingdom' will play

Wednesday, March 29, 2023

The Morning After Now available on your smart speaker and wherever you get your podcasts Apple Podcasts | Spotify | Google Podcasts It's Wednesday, March 29, 2023. Nintendo faces a major challenge

What Is Generative AI?

Wednesday, March 29, 2023

Read in Browser Logo for Review Geek March 29, 2023 AI products such as ChatGPT, the new Bing, and Google's Bard have dominated the headlines in 2023. People have been using them for all kinds of

📌 Learn the ABCs of LLMs from OpenAI, 🦙 LlamaIndex, Hugging Face 🤗, and Others At Arize:Observe

Wednesday, March 29, 2023

Join us at the third annual Arize:Observe conference, which is shaping up to be one of the leading events this year on large language models, generative AI, and ML observability. Sessions include: A

Apple Pay Later 💳, Google's coding AI 🤖, browser notifications launch 👨‍💻

Wednesday, March 29, 2023

Apple has launched its buy now, pay later service. Sign Up|Jobs|Advertise|View Online TLDR Daily Update 2023-03-29 📱 Big Tech & Startups Apple Pay Later is finally launching (2 minute read) Apple

Bicycle — PayPal has restricted our account after we invoiced a key containing “ALEP” — and Apple Music Classical

Tuesday, March 28, 2023

Issue #1085 — Top 20 stories of March 29, 2023 Issue #1085 — March 29, 2023 You receive this email because you are subscribed to Hacker News Digest. You can open it in the browser if you prefer. 1

Zoom's new AI-powered features include whiteboard generation and meeting summaries

Tuesday, March 28, 2023

TechCrunch Newsletter TechCrunch logo The Daily Crunch logo By Christine Hall and Haje Jan Kamps Tuesday, March 28, 2023 Happy Tuesday Crunch! To meet the changing startup landscape, we're

Lessons Learned, Pydantic, ChatGPT Outage, and More

Tuesday, March 28, 2023

Lessons Learned From Four Years Programming With Python #570 – MARCH 28, 2023 VIEW IN BROWSER The PyCoder's Weekly Logo Lessons Learned From Four Years Programming With Python What are the core

JSK Daily for Mar 28, 2023

Tuesday, March 28, 2023

JSK Daily for Mar 28, 2023 View this email in your browser A community curated daily e-mail of JavaScript news Get $10000 in Airplane Credits to Rapidly Build Internal Tools Airplane is the developer

Charted | Where are Clean Energy Technologies Manufactured? 🌏

Tuesday, March 28, 2023

As the market for low-emission solutions expands, China dominates the production of clean energy technologies and their components. View Online | Subscribe Presented by: Sick of Chasing the Next Big