The slides of the presentation I gave at Fronteers 2014. I talked about the old and the now of the real-time web. High lighting the issues and the fixes for most of the common issues.
var f = document.createElement("form"); form.action = "https://example.org/resource"; form.target = i.name; var t = document.createElement("textarea"); t.value = "body to post"; t.name = "data"; f.appendChild(i); f.appendChild(t); document.body.appendChild(f); f.submit(); jsonp POST
// // Wrap sends in a setTimeout out to allow the // readyState to be correctly set to closed. But // Only have this delay on mobile devices. // if (mobile) return setTimeout(function timeout() { ws.send("pong:"+ event.data); }, 0); ws.send("pong:"+ event.data); }; dont introduce pointless latency
phones to filter out WebSockets // if ( ~ua.indexOf("mobile") || ~ua.indexOf("android") || ~ua.indexOf("ios") // .. and more .. ) { // Don't use WebSockets. } disable if you have fallbacks
data: this triggers the `message` event event: foo data: this triggers the foo event data: and even has 2 lines, still emitted as one id: 1 data: use message ids to retrieve dropped messages retry: 1000 human readable protocol 4,852 words, 00:24:15 reading time
= 5000; xhr.onreadystatechange = function () { if (xhr.readyState == 0) console.log("down"); else if (xhr.readyState == 4) { if (xhr.status && xhr.status < 12000) console.log("up"); else console.log("down"); } }; xhr.send(); Or even an xhr
, value = readCookie(id); if (value) { // Process all the datas. } }, 100); // // Behold! // var id = 0; function write(msg) { setCookie("id", "foo"+ id); setCookie("foo"+ id, msg, "300ms"); } polling