What a Tool!

Issue #188  (func.props, CSS Tools, Testing/Debugging, Uncats)

In the book Secrets of the JavaScript Ninja, the authors discuss a technique called memoization, in which they make use of a JavaScript feature I wasn't previously aware of.

If you want a good intro to memoization, this article by Addy Osmani is a good start or you can grab a copy of the aforementioned book. The specific feature I'm referring to, however, is used in the book and in Addy's article.

Briefly, memoization is a way to allow a function to remember previously computed results, so as to avoid repeating highly-intensive computations unnecessarily. So a memoization function will cache results and this can be done by taking advantage of the fact that functions are objects on which you can attach properties.

Below is a rudimentary example of the basic principle of using function properties to cache values so you'll know if the function has already been run. Note that this is not a proper memoization technique, this is just to demonstrate the properties-on-functions technique:

let id = 1;

function checkItOut (fn) {
  if (fn.done) {
    fn.done = id++;
    console.log('Function run #' + fn.done);
  } else {
    fn.done = id++;
    console.log('First function run (' + fn.done + ')');

function doSomething () {
  // nothing needed here...

checkItOut(doSomething); // "First function run (1)" checkItOut(doSomething); // "Function run #2" checkItOut(doSomething); // "Function run #3"

Live demo here

In this code, the doSomething() function (paradoxically) does nothing. But each time I call it, I'm attaching the incrementing value of the id variable to that function's "done" property. This gives the function a sort of memory of itself, so I can tell how many times it's been called. In the demo you can see that each log has a new value.

As mentioned, this is not proper memoization, this is just a silly example to demonstrate that you can attach properties to functions, and how this might be useful. The book discusses this in greater detail and there are lots of sources online, including the aforementioned article, for a better understanding of memoization. You might also want to check out this memoization tool.

Now on to this week's tools!
Did you buy my previous JavaScript/DOM tips book? I've released a new one...
NEW E-BOOK! Volume 2 of JavaScript & DOM Tips

CSS and HTML Tools

Accessible color palette builder
Online tool to help designers build color palettes with combinations that conform with accessibility standards.

Open source command line tools to render HTML into PDF.

FUNctional CSS shorthand utilities. Both a handy set of functional CSS utilities, as well as a handy tool for generating functional CSS utilities.

featherweight, responsive, CSS-only navigation bar.

Ensure Animation
A simple JS module to ensure a CSS animation plays continuously through to the end animation frame.

Uses generated CSS in single-page apps to provide declarative, URL-driven control of when (or how) any elements in your page are displayed.

A universal CSS-in-JS engine built from the ground up for high-performance.

A webpack loader for extracting and processing CSS defined in other files.

A bot that writes CSS classes for HTML with deep learning.

Inline CSS for React and similar UI libraries and frameworks.

Testing and Debugging Tools

Carte Blanche
An isolated development space with integrated fuzz testing for your components. See them individually, explore them in different states and quickly and confidently develop them.

Service Mocker
The next generation front-end API mocking framework.

Include this script, then run your PhantomJS browser tests to get accessibility warning logs, or open your browser and get automatic warnings in the JavaScript console.

Catch visual bugs before they hit production. Compare your test environment with production.

In beta. CLI tool and library to gather performance metrics via Lighthouse, Google's auditing and perf metrics tool for PWAs.

An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

Keen IO
A set of powerful APIs that allow you to stream, compute, and visualize events from anything connected to the internet.

Fast MySQL hosting with HA
3 Node High Availability, Daily Backups, Auto-scaling & More. Free for 30 days.

(ads by LaunchBit) 
Fast MySQL hosting with HA

The Uncategorizables

Sizzle Analytics
Create interactive data visualizations with an easy-to-use, drag-and-drop designer.

A tool for viewing hex dumps of buffers in your browser.

An isomorphic JavaScript client for the WordPress REST API that makes it easy for your JavaScript application to request specific resources from a WordPress website.

Helps you name your business. Instantly search domains, social media handles and beautiful logotypes.

The ChromeVox (Classic) screen reader is a Chrome extension that brings the speed, versatility, and security of Chrome to visually impaired users.

The Cyber Swiss Army Knife. A web app for encryption, encoding, compression, and data analysis.

A Mozilla project focused on bringing a new set of APIs to the browser for advertising and discovering local-area web servers.

A Tweet for Thought

Hugo did a brief tweetstorm on CSS at scale.

Suggestions / Corrections

Made something? Send links via 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...

Interesting discussion on React's GitHub issues on how best to encourage developers not to ship React DEV mode to production.

Thanks to all for subscribing and reading!

Keep tooling,