Skip to content

Instantly share code, notes, and snippets.


Jake Archibald jakearchibald

View GitHub Profile
slightlyoff /
Last active Oct 10, 2020
Delivering H/2 Push Payloads To Userland


One of the biggest missed opportunities thus far with HTTP/2 ("H/2") is that we are not yet able to sunset WebSockets in favor of H/2. Web Sockets and H/2 both support multiplexing messages bi-directionally and can send both textual and binary data.

Server Sent Events ("SSE"), by contrast, are not bi-directional (they're a "server-push-only" channel) and binary data cannot be sent easily. They are, however, very simple to implement. Adding to the menagerie of options, RTCPeerConnection can also be used to signal data to applications in a low-latency (but potentially lossy) way.

Because H/2 [does not support the handshake (upgrade) that WebSockets use to negotiate a connection](

phamann / worker.js
Last active Aug 29, 2015
Simple ServiceWorker for Guardian hackday
View worker.js
console.log("Worker startup");
this.oninstall = function(event) {
console.log('Worker install');
caches.create('static').then(function(cache) {
return cache.add(
latentflip /
Created Nov 22, 2013
300ms, Fast Click & Accessibility


Caveats: I suck at accessibility, so I am probably wrong on a lot of things.

The debate

Chrome 32 on Android removes the 300ms delay on touch events for responsive sites. This disables double-tap zoom, leaving pinch to zoom the only way to zoom content. This is an accessibility concern, as for some users double tap zoom may have been the only way they were able to zoom web pages.

Why did they do it?

jakearchibald / gist:4489851
Last active Dec 10, 2015
Setting innerHTML and IE
View gist:4489851

What do you think this will output?

var div = document.createElement('div');
div.innerHTML = '<span>Hello world!</span>';
var span = div.firstChild;
div.innerHTML = '<span>Uh oh!</span>';
bradleypriest /
Created Apr 4, 2012
Convert Hex To RGB Sublime Plugin
# Add a key binding to your User Key Bindings and you're all good to go
# { "keys": ["super+shift+h"], "command": "convert_hex_to_rgb" }
import sublime, sublime_plugin
class ConvertHexToRgb(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
gre / easing.js
Last active Oct 20, 2020
Simple Easing Functions in Javascript - see
View easing.js
* Easing Functions - inspired from
* only considering the t value for the range [0, 1] => [0, 1]
EasingFunctions = {
// no easing, no acceleration
linear: t => t,
// accelerating from zero velocity
easeInQuad: t => t*t,
// decelerating to zero velocity
You can’t perform that action at this time.