Skip to content

Instantly share code, notes, and snippets.


Addy Osmani addyosmani

View GitHub Profile
peterc / domains.txt
Created Aug 20, 2013
Most linked domains from 4004 links in JavaScript Weekly from issue #1 through #143
View domains.txt
"" => 551,
"" => 84,
"" => 60,
"" => 50,
"" => 47,
"" => 45,
"" => 36,
"" => 28,
"" => 28,
"" => 25,
Integralist /
Last active Apr 25, 2020
This is how BBC News currently implements it's Image Enhancer for responsive images. Note: this is a completely rebuilt version of the code so the BBC's original source code doesn't actually look anything like the below example.

The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to but it also handles the image ratios returned (where as doesn't).

The original BBC News process (and my re-working of the script) follows roughly these steps...

  • Create new instance of ImageEnhancer
  • Change any divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
    • We set the width & height HTML attributes of the image to the required size
    • We know what size the image needs to be because each div has custom data-attr set server-side to the size of the image
    • We then set a class of image-replace onto each newly created transparent image
  • We use a 250ms setTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe
mikemurray / Gruntfile.js
Created Jul 26, 2013
Gruntfile for PHP and LESS with livereloading
View Gruntfile.js
module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),
php: {
dev: {
options: {
hostname: '',
mklabs / Gruntfile.js
Last active Dec 10, 2015
A simple example of using yeoman on an express app
View Gruntfile.js
module.exports = function(grunt) {
function noop() {}
watch: {
reload: {
files: ['public/**', 'views/**'],
tasks: 'reload'
tbranyen / backbone.cacheit.js
Created Oct 25, 2012
Cache Backbone Model and Collection fetch calls with a deferred, simple and intuitive.
View backbone.cacheit.js
* backbone.cacheit.js v0.1.0
* Copyright 2012, Tim Branyen (@tbranyen)
* backbone.cacheit.js may be freely distributed under the MIT license.
(function(window) {
"use strict";
// Localize global dependency references.
pete-otaqui / css-onload.js
Created Oct 18, 2012
Load External Domain CSS, and get a Callback in IE7, IE8, IE9, FF, Chrome & Safari
View css-onload.js
function cssLoad(url, callback) {
var promise,
resolutions = [],
rejections = [],
resolved = false,
rejected = false,
count, id;

Backbone.js and yeoman


this is a list tutorials for building web application using backbone.js and yeoman. We are building a Photo Gallery JS App from Backbone Fundamentals


afabbro /
Created Sep 21, 2012
Webkit Pseudo-Element Selectors (Shadow DOM Elements)

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:


zegilooo / backbone.localCache.js
Created Jul 23, 2012 — forked from lukecanvin/backbone.localCache.js
Online/offline syncing for Backbone
View backbone.localCache.js
Backbone.serverSync = Backbone.sync;
Backbone.pingUrl = '/Ping';
Backbone.localID = function() {
var localID = (localStorage.localID ? parseInt(localStorage.localID) : 0);
localStorage.localID = localID.toString()
return -localID;
sindresorhus / LICENSE.txt
Created Jun 4, 2012 — forked from 140bytes/LICENSE.txt
Photo Booth (
View LICENSE.txt
Version 2, December 2004
Copyright (C) 2012 Sindre Sorhus <>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
You can’t perform that action at this time.