2012-12

A new way of delivering Retina images on the web

[2012-12-06] dev, html5, html, webdev
Recently, high-resolution screens (Apple calls them Retina displays) have become popular – first on cell phones, then on tablets and now on laptops. I have been waiting for those for literally decades: all other computer components (memory, processor speed, etc.) improved predictably, but screen resolutions did not get much better over the years. The problem for web developers is that things look nicely on these displays if resolution-independent mechanism are used: fonts, vector graphics, CSS effects, etc. However, with bitmap graphics, you are forced to deliver images with many more pixels. That has the potential of greatly slowing things down on the web if you are using a Retina device.

Daan Jobsis has found an interesting solution: Use a high-resolution JPEG image, but but with an extreme compression rate (e.g. 75%):

Arrays in JavaScript

[2012-12-04] dev, javascript, jslang, jsarrays
Update 2012-12-17: New Sect. 3, “The Array constructor”.

This blog post goes deeply into how arrays work in JavaScript: they are much more like objects than you might think.

2012-11

Coercing objects to primitives

[2012-11-27] dev, javascript, jslang
This blog post looks at how JavaScript coerces objects to primitives. If you don’t know the difference between primitive values and objects, I suggest you consult my article “Categorizing values in JavaScript” at the Adobe Developer Connection. This post was triggered by the following tweet by David Bruant:
!!(new Boolean(false)) #wtfjs
The result of the above expression is true. Let us first learn about coercion in JavaScript. We can then use that knowledge to understand this result.

Jed – a JavaScript internationalization toolkit

[2012-11-21] dev, javascript, clientjs
Internationalization is still a tricky problem: we are still figuring out how to encode text properly, let alone store content in a manner that lets us translate it easily. In contrast, in other areas of web development, tools and technologies are in place so that even non-technical users can be productive. One example is content authoring – you don’t have to know how to write HTML or how to set up a server in order to publish a blog.

JavaScript inheritance: beyond the basics (video)

[2012-11-19] dev, javascript, jslang
The video recording of my JSConf EU talk “JavaScript inheritance: beyond the basics” is online (you can also download the slides). Outline:
  • JavaScript inheritance basics
  • Object exemplars
  • ECMAScript 6 classes
  • Super-references
  • __proto__

A proposal for using Canvas in web workers

[2012-11-18] dev, html5, javascript, clientjs
Ian Hickson, editor of the HTML spec, has proposed a way to let web workers use Canvas.

Variable declarations: three rules you can break

[2012-11-13] dev, javascript, jslang, jsstyle
This blog post mentions three rules that are commonly given for using var statements. And then tells you when you can break them. To make things easier to understand, I somewhat disparagingly call the rules “conventional wisdom” and breaking the rules “unconventional wisdom”. But I will also explain why the rules have been created in the first place.

Four talks on ECMAScript 6/ECMAScript.next

[2012-11-12] esnext, dev, javascript

A guide to 2ality’s posts on ECMAScript.next/ECMAScript 6

[2012-11-09] esnext, 2ality, dev, guide, javascript
This blog post gives an overview of the 2ality posts on the next version of ECMAScript, ECMAScript 6 (code-named ECMAScript.next). All of those posts have the label esnext. Consult the sitemap for a list of all guides.

Property assignment and the prototype chain

[2012-11-07] dev, javascript, jslang
This blog post examines how the prototype chain of an object affects assignments to its properties. It provides a more detailed look than the previous, more comprehensive, blog post “Properties in JavaScript: definition versus assignment”.