Category Archives: JavaScript

Faking Onload for Link Elements

Updated 2011/09/27: Rejoice! This issue has now been fixed in Firefox. Or, I Am Dynamically Loaded CSS (and So Can You!) Dynamic resource loading is one of the keys to have a performance happy web application. There are generally three different criteria we must address when making a request: cross domain security policies, asynchronous/synchronous (will [...]
Also posted in CSS | Tagged |

Maiden Voyage of the DOM Sailbloat

As many of you may already know, my day job includes managing a large and complex enterprise jQuery-based user interface component library. It’s used by all new web applications at the company, which boasts over an IT department of approximately 1500 people and hundreds of web applications. Needless to say, I get a fair volume [...]
Also posted in DOM, Projects | Tagged , , , |

Point, Charset, Match: Character Encoding in JavaScript

If you’re not familiar with the principles of character encoding, read the prerequisite Dive Into HTML 5 section on the subject. When you see issues with Character Encoding, it’s traditionally in the form of text on your page that looks like this: in Firefox or in IE. Usually, those characters mean that the character encoding [...]
Also posted in Web Browsers | Tagged , |

Internet Explorer Array.sort Unreliable

What would you expect to be the result of executing the following code? // Create a medium size array, at least 100 items var obj = []; for(var j=0, k=150; j<k; j++) { // the value here doesn't matter. obj.push('ABCD'+j); }   // Sort the array alphabetically. obj.sort(function(m,p){ m=(''+m).toLowerCase(); p=(''+p).toLowerCase();   if(m > p) return [...]
Posted in JavaScript | Tagged , |

Trash that “Back to Top” Link

It would seem that perfection is attained not when no more can be added, but when no more can be removed. - Antoine de Saint Exupéry While most would argue that the principles espoused in the above quote might also be applied to the quote itself, it would serve us better to consider how we [...]
Also posted in Interface Design | Tagged , |

Quick Performance Tip: jQuery and addClass

Abstractions are helpful and dangerous. But the more we know about a library’s internals, the less danger we’ll be in later. Here’s an issue I ran into where I had assumed that jQuery would be optimized for this case, but it wasn’t. I’ll go over my bad assumption and how to workaround it. As of [...]
Posted in JavaScript | Tagged , |

Performance Caveat with jQuery Selectors and Live Events

Prerequisite: Knowledge/Experience with jQuery Live Events (new in jQuery 1.3), and the concept of Event Delegation. When developing on the front end, it’s easy to prioritize correctness over performance. Performance is the step child that gets lost while you’re pulling your hair out worrying about cross browser compatibility. It’s very important to regularly benchmark your [...]
Posted in JavaScript | Tagged , |

Scare Your Visitors with this JavaScript Gravatar Plugin

Here's a use case. An unregistered visitor visits your blog, and decides that your content is so good that it merits a comment! Congratulations, you've fooled them! But since they're leaving a comment, why not show them a preview of their gravatar?
Also posted in Projects | Tagged , |