JavaScript – recursively construct (provide) a namespace

Use like:


JavaScript – get index of child element


Change content of before or after psuedo element with JavaScript

Set the content to an attribute, and change the attribute with script.


Simple JavaScript to Query Parameter Serializer


Seriously Simple JavaScript Cookie Management

Here’s the basic idea of one way to manage cookies with JavaScript. As always, there are more robust libraries available, but here’s the upshot:


Why does indexOf return -1

Both Array.prototype.indexOf and String.prototype.indexOf (as well as all their counterparts in other languages) return -1 when a match is not found. This can seem less-than-obvious to new learners. I often use this example to illustrate why:

Simple requestAnimationFrame polyfill

While there are definitely better versions, as always I’m concerned with the fundamental function – and for requestAnimationFrame it’s pretty straightforward:

Basic JavaScript Tasks (vanilla, framework agnostic)

Create a reference

Create a function

Create an array

Create an object

Assign properties to an object

Iterate through an array

Iterate over an object

Get a reference to an element

Get a reference to a collection of elements

Modify an element’s style

Create an […]

JavaScript – get window reference from element

jQuery – how to raise hide and show events

Using my simple monkey-patch plugin found here:, this is pretty simple…

That’s it – now you can listen for “hidden” and “shown” events normally…

Note that this only hooks into the $.fn.hide and $ methods – hiding an element via .css would not trigger the event.