Steve Fenton


You can subscribe to the javascript tag micro-feed.

Adjusting Content for Network Speed

There is an experimental specification on the W3C for a navigator.connection Network Information API that provides a rough indication of connection speeds, which you can use to adjust your content. Like many of the modern API proposals, there is concern over it’s use in browser fingerprinting – but hopefully a course-grained version of this will […]

This is a little funky script to intercept AJAX requests and raise a simple custom event for everything else in your app to listen to. To use this, you just need to listen for a custom event named `AjaxDetected`. The method, url, and any data is passed in the event detail. document.body.addEventListener(‘AjaxDetected’, function (e) { […]

Although it has been abused with an enthusiasm that borders on the insane, there are good reasons to use the Notifications API in your web apps. For example, you write a mail client that allows the user to request notifications for key contacts… if they are browsing your web-based app, they should get notifications. To […]

Avoid expensive innerHTML manipulation with insertAdjacentHTML

It is pretty well known these days that fiddling with innerHTML is terribly inefficient. It triggers serialization, and it can result in invalid markup. Nevertheless, you’ll still find this being done in many applications. elem.innerHTML = elem.innerHTML + ‘<a href=””>Visit Example Dot Com</a>’; // or elem.innerHTML += ‘<a href=””>Visit Example Dot Com</a>’; You can avoid […]

Set a minimum font size

This is just a little script I needed to use to increase text size conditionally. It only increases text below a minimum size and leaves everything else. Please also see a more recent post on CSS Clamp! (function () { var minFontSize = function () { $(“.content-zone *”).each(function () { var $this = $(this); if […]