Skip to content

Instantly share code, notes, and snippets.

View alexyoung's full-sized avatar
💤

Alex Young alexyoung

💤
View GitHub Profile
@alexyoung
alexyoung / 2011-11-28-flickr-breakdown.md
Created November 27, 2011 14:58 — forked from voidfiles/gist:1397205
Breakdown of flickr's pre-script loading event handler

Production Tear Down: How Does Flickr Handle Loading Scripts Asynchronously?

If you are using an async loader, or even if you are just putting your scripts at the bottom of your DOM, you have a problem. In some cases your scripts will load after the user has clicked on something that requires a JavaScript function to handle the click. It's possible you have a pure HTML version, but if the user has JavaScript we want them to use it, even if the JavaScript hasn't loaded yet. You need some way of handling events before all of your assets have finished loading.

There are a number of ways we could do this, but it's helpful to look at a working implementation. This is going to be a two part series. First, we are going to look at how Flickr does this. In the second part, we can take the code that Flickr uses and extract the main features so that anyone can use the code.

In all of the code that Flickr loads before the body this is the part that matters to us: [Isolated actionQueue Code](https://gist.github.com/139

Scenario Outline: searching
Given I am logged in as a stuff
And the following losses records:
| firstname | lastname | lost_at | bus_type | description | closed_at |
| Luke | Skywalker | 2009-01-23 | Nightrider | lightsaber | |
And the following findings:
| found_at | found_by | bus_type | description | picked_up_by | picked_up_at | loss_id |
| 2008-12-24 | Daniel | Nightrider | walkie-talkie | | | |
| 2009-05-24 | Joel | Flibco | silver ring with Diamond | Francois | 2009-02-03 | 1 |
And I am on the findings page