JavaScript Tutorials
JavaScript Polling
Polling with JavaScript is one of those ugly but important functions within advanced front-end user experience and testing practices. Sometimes there isn't the event you can hook into to signify that a given task is complete, so you need to get your hands dirty and simply poll for...
Reducing Memory Leaks when Working with Animations
I have been doing a lot of work with Snap.svg recently and you may have already seen an article a while back regarding SVG animations. After the article had been published, I took some time out to review the code I had written and found that...
ES6: Features By Testing
TL;DR Use the FeatureTests.io service to perform feature tests of ES6+ features. The results of these tests are cached by default in the user's browser, and shared across all sites the user visits that use this service. In the bootstrapper for your site/app, check the results of...
Preventing Side Effects in JavaScript
JavaScript is very dynamic these days but I still see a lot of legacy code, whether it be for optimal backward compatibility or simply that the code hasn't been maintained. One of the practices that makes me cringe is coding that creates unwanted side effects. What's a side...
Geolocation API
One interesting aspect of web development is geolocation; where is your user viewing your website from? You can base your language locale on that data or show certain products in your store based on the user's location. Let's examine how you can...
fetch API
One of the worst kept secrets about AJAX on the web is that the underlying API for it,
XMLHttpRequest
, wasn't really made for what we've been using it for. We've done well to create elegant APIs around XHR but we know we can do better. Our effort to...Basic AJAX Request: XMLHttpRequest
There are a number of common front-end tasks that many of us never touched the deep, dirty APIs for because our beloved JavaScript frameworks have provided easier ways to work with them. That's why I wrote How JavaScript Event Delegation Works, Do a Basic HTTP Request with...
Element matches / matchesSelector
I was thinking about HTML elements and selectors recently. We usually start by searching for an element(s) via
querySelector
/querySelectorAll
, which makes sense, but what if you want to validate that an element that wasn't specifically selected matches a given selector? For example, say you have a...MutationObserver API
One of my favorite web tricks was using CSS and JavaScript to detect insertion and removal of a DOM node, detailed in Detect DOM Node Insertions with JavaScript and CSS Animations. The technique and blog post were published during a time when we didn't have a reasonable...