Quick Tips Tutorials
Safe Function Calls with attempt
As browser implement new APIs, the truth is that though the APIs provide more power, I'd argue they bring about more volatility. Whether it's the API that's the issue or us trying to use it, you're bound to run into errors which may break parts of...
Remove UTM Parameters from URLs
If you've ever worked on a social media campaign, you're probably familiar with the UTM tracking pieces of a URL which allow you to tie visits and pageviews with a given campaign. They're a marketing person's dream but ugly for end users to look at. And if you don't want your statistics...
Do a Basic HTTP Request with Node.js
I'm currently working on adding client-side testing to the Mozilla Developer Network (MDN). I'm using Intern, a JavaScript-based WebDriver API created by my former employer SitePen. MDN has used its own Persona login service for years, and since many key features of MDN require...
Element.offsetHeight for Visibility
One of the (perceived) tricky tasks within front-end coding is checking if an element is visible or not. The very naive way of checking if an element is visible (i.e. has presence or takes up space on the page) is by checking its display style value: Notice...
JavaScript: Constructor Auto-Execution with new Keyword
JavaScript is full of small, interesting facets that can trip you up, make you laugh, or make you cry. This post is about an interesting one. Those of you that have worked with JavaScript functions, and in a way JavaScript "classes" (as you used with MooTools)...
Accessibility Tip: Empty alt Attributes
As mostly a self-taught developer, my impressions of best practices were self-formed, and over the years I've realized many of those impressions were incorrect or the standards associated with them had quickly changed. One small but important practice is the usage of
alt
attributes onimg
tags, and I had thought...Get Real Image Height and Width Dimensions
One massive help provided by CSS in aiding developers to create responsive designs is
max-width
. I always setimg
,iframe
, andembed
tags tomax-width: 100%
so that they aren't allowed bleed through their parent and stretch the page on mobiles, but I recently asked myself if it...Detecting Google Universal Analytics
Just about everyone uses Google Analytics and why shouldn't they? The amount of useful data you can pull from Google Analytics, especially if you use custom dimensions, is amazing. Whether you're A/B testing, trying to increase engagement, or improve sales, Google Analytics is just about perfect. I recently experimented with...
Node.contains: Check if a Node is a Child of Another Node
There are loads of basic, native JavaScript methods that many developers don't know about. Many people don't know about the Element.classList API, for example, so
className
management becomes another case for needing a JavaScript toolkit for even the most basic tasks. Another case is checking for node...Wrapping Text Nodes and Elements with JavaScript
When you work on a site that relies on a given JavaScript toolkit, you unintentionally end up trying to solve problems within the bounds of the toolkit and not the language. Such was the case when I tried wrapping text (possibly including HTML elements) with a
DIV
...