Communicate with certainty
and your Voice will be heard.

Category Archives: web development


The Thinking Mechanism is a series of weekly posts, published on Fridays, covering the ideas The Mechanism is thinking and talking about with our peers and clients.

In the U.S. this weekend is Memorial Day weekend, the official start of summer. Many people travel to visit family and friends or just to take their first trip to the beach. In the spirit of the holiday weekend we are going to do something different. Instead of sharing the items we’ve been talking about we are going to introduce you to two services we love and share items that you could enjoy while commuting to your destination or while taking some deserved time off.

Once you discover Instapaper you wonder how did you manage without it. Created by Marco Arment, co-founder of Tumblr and coffee aficionado, Instapaper is a simple tool to save web pages to read later. The text is stripped out of any web page and becomes available, via apps on most mobile devices, for you to read when you have the time. It is also available online through the Instapaper website. Instapaper is time-shifting for text, TiVo for words.

Longreads is the perfect compliment to Instapaper. Founded by Mark Armstrong, Longreads posts links to new stories every day — they include long-form journalism, magazine stories from your favorite publications (The New Yorker, Esquire, The Atlantic), short stories, interview transcripts, and even historical documents. The site has a brilliant search feature that allows you to filter articles based on length, so you can find the perfect article to read in the amount of time you have available.

In the age of Twitter and Facebook status updates, these two services encourage long-form reading. Here are some of the articles we’ll be reading this weekend, as discovered through Longreads:

Error Message: Google Research Director Peter Norvig on Being Wrong
(Kathryn Schulz, Slate, Aug. 3, 2010)
Time to read: 16 minutes (4,050 words)
Norvig explains what happens when a company (in this case Google) takes an engineering-centric approach to its products and business. First, it means that errors are actually a good thing.

Apple & Design: The Man Who Makes Your iPhone
(Frederik Balfour and Tim Culpan, Businessweek, Sept. 9, 2010)
Time to read: 21 minutes (5,204 words)
Foxconn founder Terry Gou might be regarded as Henry Ford reincarnated if only a dozen of his workers hadn’t killed themselves. An exclusive look inside a postmodern industrial empire.

Later: What Does Procrastination Tell Us About Ourselves?
(James Surowiecki, The New Yorker, Oct. 11, 2010)
Time to read: 14 minutes (3,574 words)
Take comfort in this exploration of the “basic human impulse” of putting work off.

Master of Play: Shigeru Miyamoto, Nintendo’s Man Behind Mario
(Nick Paumgarten, The New Yorker, Dec. 13, 2010)
Time to read: 37 minutes (9366 words)
Jamin Brophy-Warren, who publishes a video-game arts and culture magazine called Kill Screen, told me that there is something in the amplitude and dynamic of Mario’s jumps—just enough supernatural lift yet also just enough gravitational resistance—that makes the act of performing that jump, over and over, deeply satisfying. He also cited the archetypal quality of Mario’s task, that vague feeling of longing and disappointment which undergirds his desperate and recurring quest for the girl. “It’s a story of desire,” Brophy-Warren said.

Twitter Was Act One
(David Kirkpatrick, Vanity Fair, March 3, 2011)
Time to read: 18 minutes (4,543 words)
“The Facebook Effect” author David Kirkpatrick on another Silicon Valley superstar—Twitter and Square founder Jack Dorsey. In submitting to his first in-depth profile, we learn about the events the led to him stepping down as CEO [since then he has returned to Twitter as CEO], his long-term goal (to become mayor of New York City), and his earliest career experiences.

Cranking
(Merlin Mann, 43 Folders, April 22, 2011)
Time to read: 12 minutes (3,068 words)
A disappearing dad with a looming book deadline examines his priorities, and promises changes.

Håkon Wium Lie

Photos and discussion of CERN and Tim Berners-Lee. How the web was actually developed by Tim at CERN. Pretty hilarious.

CSS a response to potential destruction of HTML's markup language with presentation elements. Currently CSS still relies too heavily on images and the occasional table hack.

HTML5 + CSS3 = WEB8. CSS3 is not a single specification, a series of specifications.

CSS1 could style text in an element. Some borders. A revolution when it came out.

For this presentation, Håkon is using a special build of Opera that isn't publicly available.

1
text-shadow

. Web font: Safari, Firefox and Opera.

Håkon believe web fonts is going to be the big new thing. Will create a pre- and post-font Web.

1
@import url(path/to/font);

1
font-family:Cardiff;

IE is the only one that does not not support this. Argument now breaks out between Håkon and Pete LePage

IE has supported a broad range of fonts since IE 4, but .EOT. However, the above @import is all TTF. IE uses .EOT because font foundries want support for DRM. Check out Fontdeck and Typekit.

At Standards.Next, IE pledged support to add support to TTF along with EOT.

rgba()

1
background: rgba(0, 0, 255, 0.4);

See Molly's presentation.

A review of Opera's support for the CSS 3 features discussed by Andy Budd.

Opera Unite

Turns browser into a server. Allows people to access your machine via

1
http://

. Can be quite useful.

It's not the cloud. This service is close to machine and useful for local collaboration. Millions of phones use Opera. Peer-to-peer model. Can take picture and easily

Question/Answer

Q: When will the geolocation build be integrated with the shipping version?

A: Not sure; no date yet. Will probably not occur until the standard is more fixed.

Pete LePage
Senior Product Manager, Developers & Security for IE

IE 8

IE 8 is a hybrid, has two engines; IE 9 will have three engines: IE 7, IE 8 and IE 9. This way can ensure site works in future versions of the browser.

IE 8 supports session and local storage (see presentation by Marcus Lofthouse to the New York Web Standards Meetup). Added addition to spec: a way to remove all.

Mutable DOM prototypes: take a DOM element and add properties/methods to it. Add method to

1
img

. There are a number of things not implemented in IE 8. Can write a chunk of JavaScript that adds functionality to browser. This will be used by people writing the JavaScript frameworks (jQuery, Dojo).

Native JSON support.

Network events

CrossDocumentMessaging and CrossDomainRequest

Selectors API

Fixed getElementById.

Demos at ie8demos.com (browser-sniffs and only wants to work in IE 8).

IE 9

  • Faster; speed is important. Finally comparable to FF.
  • A lot of work on standards-support. Will implement border-radius. Acid3 score went from 20 to 32. IE 8 Current CSS3 support is vertical-text. Hope to more than double it in IE 9. ;)

Questions/Answers

Q: Why always trying to play catch up? Why not just adopt Webkit?

A: A lot of things that make adopting Webkit or Gecko more difficult than it seems.

Q: Any release date for IE 9?

A: No dates as of now

Q: Still trying to get Canvas out of the spec for HTML5?

A: Not sure; might be a miscommunication

Q: Any major updates planned for IE 8?

A: Probably not; next major version will be 9. Security updates will be released for 8, but the rendering engine will not change.

Molly Holzschlag

RGB: Additive synthesis

Red, Green, Blue: Add colors to get result color. In print world, subtractive. Remove color to get result. R + G + B = white

RGB color notation

RGB in percentage values or RGB in integer values. Not equivalent; so don't use both (mix in a single rule)!

NOT

1
rgb (60, 100, 50%);

Firefox and Opera will ignore the incorrect rule. Safari and IE (5–now) will attempt to correct and end up with a severely washed-out result.

HSL color

Hue, saturation and lightness. Easier and more intuitive way to get to colors we want as designers. Value from 1–360, then adjust saturation and lightness.

  • Hue value comes first, using the hue's angle on the color wheel as represented by an integer.
  • Saturation comes next, using the percentage of saturation you'd like
  • Lightness is next, using the percentage of lightness you' like

HSL advantages

  • Not CRT specific
  • Easier, more intuitive to work with
  • Working with a set of colors allows for easy palette creation
  • Reduces errors
  • Reduces dependency on charts and other value lookup tools

As adjust saturation, lightness, base-hue remains the same.

RGBA and HSLA

Alpha transparency for both RGB and HSLA.

Notation is the same in both. a value is alpha transparency from 0–1.

Allows for fully opaque to fully transparent.

1
hsla(0, 100%, 50%, .25)

Supported by Firefox, Webkit and Opera.

Questions/Answers

A: Best article out there on HSLA is Wikipedia. Useful to have the color wheel.

Q: Why is a value decimal instead of percentage?

A: Not sure. No one remembers a discussion about it.

Q: Is this part of the spec?

A: Yes. It is all part of the CSS3 color module.

Andy Budd

Border radius

1
-webkit-border-radius: 30px;

Safari, Chrome, Webkit suppot it. Gecko does as well, but the syntax a bit different. IE 9 to support border-radius as well.

  • Currently not supported in Internet Explorer
  • Problems with images overlapping corners

Border image

1
border-image: url(border.png 25% 12% 30% 20%;

1
-webkit-border-image

1
-moz-border-image

An ad-hoc discussion of why vendor-specific extensions exist:

  • Useful for testing out features, instead of a general release and then breaking general release codes.
  • To become a proper standard, must exist with two different implementations.

Multiple background images

Example Silverback app

1
background-image: url(path), url(path);

1
background-position: 150% 0, 40% 0;

Older browsers get no background a'tall.

Borders and backgrounds are coming soon (general release).

Gradients and reflections

Buttons are generally bitmap images. Can now create a beautiful button using gradient and reflection purely in CSS.

1
-webkit-gradient(linear, left top, left bottom, from(#abe143), to(#cccccc));

1
-webkit-box-reflect: below 2px;

[Will need to do some demos of these things]

box-shadow

Box shadow property attaches one or more shadows to box. Offset, size, blur and spread. Can also do inset box shadows. Exactly the same as working with box shadows in Photoshop.

Example: http://2010.uxlondon.com/

Transforms

Can scale, rotate, flip, skew, etc. Can use translate to create animations/move over time

Demos: http://remysharp.com/demo/rubiks/
http://webkit.org/blog-files/leaves/

Questions

Q: Box-shadow has recently been removed from the spec, even though it has been implemented. Should we use it or not?

A: When younger, Andy Budd would have said, "If it's not in the spec, don't use it." Now, he's more tolerant. Not as impressed with the W3C as he once was. Doesn't always give designers what they need.

Molly: It has been difficult to get designers involved with the creation of the spec. As a volunteer, tech spec heavy group, difficult to keep designers active.

Q: Regarding animations, between JavaScript, Canvas, SVG and CSS, what do you think the best technology to bet on is?

A: Easiest is best, why Andy favors CSS.

Q: For individuals, CSS might be easy, but not so for large organizations where designers/developers have a large codebase to absorb. And what about object-oriented CSS? And mixins, variables, etc? (Nicole Sullivan's work)

A: Andy is opposed, because CSS is used more often by designers than programmers. Thinks it’s an interesting concept, but not necessarily the answer.

Having gone from table-based design to CSS-based layouts, works well with 5-6 page templates, but with very large sites, doesn’t necessarily scale. This is where an object-oriented CSS approach comes in use.

Andy thinks the framework is not useful. There is no one size fits all framework. He develops site-specific frameworks. A lot of libraries and components that are re-usuable, but specific to site.. Hates Blueprint, 960.

Q: Tips/techniques on testing?

A: Creates a central page that uses all components. Creates a type of regression testing. If change anything, can scan that page to see if anything is broken. Testing does not occur at the end of the process; testing should be occurring throughout the process. This includes cross-browser. Use VMware.

HTML5 Part Three: Session, local storage, Web databases, and application cache

Marcus Lofthouse (tunecore.com) will continue the HTML5 series by exploring the following web storage techniques:

  • Session and Local Storage—providing a javascript accessible interface to key-value storage.
  • Web Databases—relational database support for storing structured data inside the browser.
  • Application Cache—providing the ability to define a list of files the browser should store locally and not request from the server again (until you explicitly signal the browser that you have something new to offer). Strategically used, this allows for the creation of web applications that can be used completely offline.

HTML5 storage techniques

  • Session/local storage
  • Client-side browser databases
  • Application cache

Current techniques

  • Server-side storage
  • Cookies: often used for customization
  • Plugins (Google Gears): Not used as extensively as server-side storage or cookies

Some issues (server side)

  • Requires persistent connection to the internet
  • Large data sets have to be downloaded each time the page is loaded
  • Can be processing intensive

Some issues (cookies)

  • Difficult to work with in JavaScript
  • Get sent to and from the server with each request (whether used or not)
  • Limited to 4k depending on the browser

Session storage

  • Allow 5–10 mb of storage
  • Works in Firefox, Safari and IE 8
  • Easy to use

Using session storage

1
sessionStorage.setItem(key, value);

1
sessionStorage['key'] = value;

1
sessionStorage.key = value;

1
sessionStorage.getItem(key);

1
sessionStorage.length;

1
sessionStorage.removeItem('key');

1
sessionStorage.clear();

Local storage

  • Exactly the same—only different
  • Different in scope & persistence

Session storage scope

  • Accessible only to one instance of a browser tab or window
  • All data is destroyed when window is closed
  • Newly created windows or tabs will get a unique copy of sessionStorage; they will diverge from that point forward
  • Prevents data leaking between windows

Local storage

  • Accessible to all windows or tabs (for site—obeys same origin policy)
  • Persistent storage between browser restarts

The base features are the same cross-browser, but each browser has its own specific extensions.

More than simple key-value pairs; can also store large chunks of XML or JSON.

Client-side database

  • Provides persistent storage of well structured data
  • Currently only supported in Webkit

Comments and concerns

  • No standard web SQL dialect
  • SQLite doesn't enforce types
  • SQLite doesn't enforce data lengths

Positives

  • Asynchronous DB calls keep the UI responsive
  • JS interface provides an easy way to clean your data and avoid SQL injection attacks
  • All database calls wrapped in transactions
  • Database versioning

Opening a database

1
var name = 'cheesedb';

1
var version = '1.0';

Execute SQL statements; two flavors

1
executeSQL(sqlStatement, arguments);

1
executeSQL(sqlStatement …

Security issues

  • Same origin policy
  • Tools can allow users to modify their own local data.

What is an application?

  • Desktop: compiled source, images, config/data files
  • WebApp: HTML, images, CSS, JavaScript, config/data files
  • Largest difference is delivery mechanism: webapps require you to access the sources via the internet

Application cache

  • Allows you to instruct the browser to keep a local copy of a set of files.
  • These files can be used offline, but more importantly won't request the resource from the server until told to do so again.
  • If you specify all of the files needed to run your application you will be able to run it offline.

Application caching

  • Cache manifest

Cache manifest

  • Simple text file
  • First line contains
    1
    CACHE MANIFEST
  • Following lines contain paths to files to be cached
  • Document is declared as HTML5: <!DOCTYPE html>
  • The cache manifest file is served with …
  • New attribute for the
    1
    html

    element:

    1
    &lt;html manifest="cache.manifest"&gt;
  • The cache manifest automatically includes the file it is called from.

Other options

  • Network section for content never to be cached

Updating cache manifest

  • Browsers check to see if the cache file has been updated by doing a byte by byte comparison of the cache manifest file, not by looking to see if the server resources have been updated
  • If the file has been changed the browser will download the new assets in the background
  • Cache updating is atomic. If any file is not found, the cache manifest will re-download everything (304 or 200 requests).

Batteries about to fail; signing out

Links to resources from last month's HTML5 Part Two: Canvas, Web Forms 2.0, Audio and Video presentation to the New York Web Standards Meetup by Mike Taylor (TuenCore) and Jeffrey Barke (theMechanism). Thanks to everyone who attended!

See also: