Reminiscing about the history of the <script> tag ritual

When JavaScript was first introduced, browsers treated the contents of script tags as regular content. To be Netscape 1.0 compatible, you had to add HTML comments. Even though the comments became unnecessary in the mid 1990s, they are STILL used in many places around the web today.

Read ›

Simple and Effective Fix for the WordPress wpautop() Madness

You may be familiar with the problems related to WordPress wpautop() function. The most notable problem is that your WordPress pages will leave you with empty paragraphs. The empty paragraphs can't be removed by simply removing <p></p> with a find and replace. It turns out that the result HTML doesn't actually have <p></p>. But the empty paragrapsh do show up in the DOM tree.

Read ›

Chrome V8 Creators: `with` and `delete` are "Dog Slow"

On a recent podcast the creators of Chrome's V8 JavaScript Engine, Lars Bak and Kasper Lund, discussed some of the challenges of writing a JavaScript compiler. They cautioned that using with or delete is "dog slow". When you use with, V8 has to wait until run time to resolve the scope chain. When you use delete V8 has to transform your object from a highly-optimized class structure into a slower hash table.

Read ›

JavaScript Selector Library Supports CSS4!

I was reading DailyJS and ran across this great JavaScript selector library called Sel.

It can select elements using the very brand new CSS4 features. The following are some examples.

Read ›

Firefox Extensions: Add Button to Nav Bar

The new Add-On SDK for Firefox rocks! It is so easy to create and test using the cfx command line utility.

One thing that is conspicuously absent is the ability to add a button to the navigation toolbar. You know, the toolbar that holds the URL bar and bookmarks button. It took a fair amount of research and trial and error, but it turns out to be a small bit of code.

Read ›

jsPerf.com Introduces Graphs

If you haven't seen jsPerf.com, you've been missing out. You can benchmark pieces of JavaScript against each other. The site was created by Mathias Bynens (blog) and the benchmarking engine, Benchmark.js, was created by John-David Dalton (blog).

JavaScript is by nature only acurate to 1 millisecond, and some browsers are acurate to only 15 milliseconds in practice. Benchmark.js uses higher resolution timers where available. For browsers it utilizes a Java Applet to access a high-precision timer. When Chrome or NodeJS are run with a --enable-benchmarking flag, it makes use of a native microsecond timer.

Read ›

Canvas Fountain Demo

I got a kick out of this canvas demo from Mozilla.

Read ›

A JavaScript Phone: Microsoft's Night Terrors

Today Mozilla announced their proposal for providing phone-like functionality to the browser in this hacks.mozilla.org article. Their goal is to provide "basic HTML5 phone experience within 3 to 6 months."

Specifically, they want to provide JavaScript APIs for accessing the phone dialer, address book, SMS, and more. We already have support on Android and iOS for getting geolocation data from GPS. There is also some support for taking photos using only JavaScript. And don't forget the FileReader and FileWriter APIs.

Read ›

Using JavaScript in Photoshop

Did you realize that you can write macros and scripts for Photoshop in JavaScript? Yes, JavaScript is everywhere. JSPatterns.com has a great article explaining how to write JavaScript for Photoshop.

In his example, author Stoyan Stefanov takes a layered Photoshop file, shows and hides certain layers, and saves the resulting image to a .png file. The files he saved were charts of guitar chords--156 images saved in an instant.

Read ›

JSON++: The Structured Clone Algorithm

I was using window.postMessage yesterday and ran into this nugget on hacks.firefox.org:

The window.postMessage() method now uses the structured clone algorithm to let you pass JavaScript objects instead of just strings from one window to another.

The Structured Clone Algorithm is an HTML5 specification for serializing complex data structures. The following are data structures that the algorithm can store that JSON cannot.

Read ›