AJAX Tutorials
fetch with Timeout
A few years back I wrote a blog post about how write a
fetch
Promise that times out. The function was effective but the code wasn't great, mostly becauseAbortController
, which allows you to cancel a fetch Promise, did not yet exist. With...How to Cancel a Fetch Request
JavaScript promises have always been a major win for the language -- they've led to a revolution of asynchronous coding that has vastly improved performance on the web. One shortcoming of native promises is that there's no true way to cancel a
fetch
...until now. A...How to Detect an Ad Blocker
One of the unspoken rules of the internet is that most content is "free"... at the cost of webpage being littered with advertisements and trackers. This was't a big problem in the early internet days but trackers and advertisements have become so intrusive and unapologetically aggressive...
async & await
JavaScript promises were a revelation in JavaScript, providing an alternative to the JavaScript callback hell we'd quickly found ourselves in. Promises also allowed us to introduce and better handle asynchronous tasks. While promises were an improvement over callback hell, they still require lots of
then
s...Create a Basic Loader with JavaScript Promises
I've used JavaScript loaders for years; whether it was the Dojo loader, curl.js, or even using jQuery as a JavaScript loader, it's incredibly useful to request a set of resources and react once they've completed loading. Each JavaScript loader is feature-packed, efficient, and does a wonderful job...
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...
Get Bitcoin Value with curl or Node.js
Last year I started dabbling in bitcoin. Of course I was immediately cocky as bitcoin value went up 20% as soon as I bought it, then was humbled as bitcoin's value tumbled down 50%. From boathouse to outhouse. From caviar to ramen noodles. It was brutal. Anyways, I was...
5 Ways to Make Your Site Smaller and Faster
Confession: I'd say once a week I genuinely wish I was a kid who spent his work day cutting grass and doing landscaping. Why? Because at the end of the day, they are able to say "the grass is cut, the job is complete." As Web Developers, we...
Pub/Sub JavaScript Object
There are three keys to effective AJAX-driven websites: event delegation, History management, and effective app-wide communication with pub/sub. This blog employs of all of these techniques, and I thought I'd share the simplest of them: a tiny pub/sub module I use on this site. If you've...