if the news here is old, blame me

JavaScript Archives

9 Anti-Patterns Every Programmer Should Be Aware Of

June 16, 2015 by - Leave a comment

A healthy dose of self-criticism is fundamental to professional and personal growth. When it comes to programming, this sense of self-criticism requires the ability to detect unproductive or counter-productive patterns in designs, code, processes, and behaviour. This is why a knowledge of anti-patterns is very useful for any programmer. This article is a discussion of […]

Read More »

Learning JavaScript Design Patterns

June 29, 2013 by - Leave a comment

A book by Addy Osmani Volume 1.5.2 Learning JavaScript Design Patterns is released under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 unported license. It is available for purchase via O’Reilly Media but will remain available for both free online and as a physical (or eBook) purchase for readers wishing to support the project.   Preface […]

Read More »

JavaScript Module Pattern: In-Depth

March 12, 2013 by - Leave a comment

The module pattern is a common JavaScript coding pattern. It’s generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I’ll review the basics and cover some truly remarkable advanced topics, including one which I think is original. The Basics We’ll start out […]

Read More »

How Do I: Structure Applications

October 12, 2012 by - Leave a comment

This is part two in a series of "How Do I" articles (part one, Animation, is here). Structure Philosophy These days, I think the difference between a "Site" and an "Application" is very small. Sites may start small, be less interactive and have less state than Applications, so they don't necessarily need tools and libraries […]

Read More »

How Do I: Animate

October 1, 2012 by - Leave a comment

Animation Philosophy When animating, either massive thousand-part experiences or single on-off effects, I prioritize framerate and the ability get the right "feel" from the animation. Both goals are about Control, so I do nearly all of my animations in Javascript instead of CSS. Javascript allows me to control all of my animations from a single […]

Read More »

Saner HTML5 History Management

July 25, 2012 by - Leave a comment

Hashchange This event is quite simple. Whenever the window.location.hash property changes, by following a link, setting the property, editing the URL bar, or using back/forward to move through browser history, the “hashchange” event is fired from the window. Using it is really easy: window.onhashchange = function() { alert("hash changed!"); }; window.location.hash = Math.random(); // alerts […]

Read More »

Writing Testable JavaScript

July 8, 2012 by - Leave a comment

The engineering culture at Twitter requires tests. Lots of tests. I haven’t had formal experience with JavaScript testing before Twitter, so I’ve been learning a lot as I go. In particular, a number of patterns I used to use, write about, and encourage have turned out to be bad for writing testable code. So I […]

Read More »

Spying Constructors in JavaScript

May 12, 2012 by - Leave a comment

The most common complaint with using closures to keep private variables in JavaScript is that it makes debugging harder. This complaint definitely holds water, and the loss of easy debugging and inspection using the Module Pattern is a serious concern. This is where one of JavaScript’s non-standard but well-supported features comes in: the debugger statement. […]

Read More »

Debugging Closures and Modules

April 13, 2012 by - Leave a comment

The most common complaint with using closures to keep private variables in JavaScript is that it makes debugging harder. This complaint definitely holds water, and the loss of easy debugging and inspection using the Module Pattern is a serious concern. This is where one of JavaScript’s non-standard but well-supported features comes in: the debugger statement. […]

Read More »

JavaScript Module Pattern: In-Depth

March 12, 2012 by - Leave a comment

The module pattern is a common JavaScript coding pattern. It’s generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I’ll review the basics and cover some truly remarkable advanced topics, including one which I think is original. The Basics We’ll start out […]

Read More »