Detect “Do Not Track” with JavaScript
Do Not Track is an excellent idea. The DNT website describes it best:
Do Not Track is a technology and policy proposal that enables users to opt out of tracking by websites they do not visit, including analytics services, advertising networks, and social platforms. At present few of these third parties offer a reliable tracking opt out, and tools for blocking them are neither user-friendly nor comprehensive. Much like the popular Do Not Call registry, Do Not Track provides users with a single, simple, persistent choice to opt out of third-party web tracking.
The preference is sent from the client to the server via a HTTP header but you can also get its value using JavaScript:
// "1" or "unspecified"
if(navigator.doNotTrack == 1) {
// Do (or don't do) stuff.
}
If you wanted to be extreme about honoring your user's preference, you could use that to lazyload (or not) advertising, analytics, or other utilities. Probably a bit extreme but it's there for you to use!
My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first...
You've probably heard the talk around the water cooler about how promises are the future. All of the cool kids are using them, but you don't see what makes them so special. Can't you just use a callback? What's the big deal? In this article, we'll...
Last week we created a very simple MooTools slideshow script. The script was very primitive: no events and no next/previous controls -- just cross-fading between images. This tutorial will take the previous slideshow script a step further by:
Adding "Next" and "Previous" controls.
Adding...
A long time back I coded a MooTools class called OpenLinks. The class is quite useful but the code...sucks. I've gotten much better with MooTools over the past years so I thought I'd go back and update the class to be better, faster...
Is the resulting value always a string or an integer except when unspecified (then it is a string), and are the values you stated the same cross-browser (especially the unspecified value)?
I really like how medium handles DNT.