Steve Fenton


You can subscribe to the javascript tag micro-feed.

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 […]

Manipulating variables in JMeter

There are many reasons for manipulating variables in JMeter, especially when you are loading data from a CSV data set config element. You might want to trim a JMeter variable, or grab just a substring. In all of these cases, your existing knowledge of JavaScript can come to the rescue. Wherever you were about to […]