Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Collaborative JS
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Ben Foxall
August 10, 2016
Technology
170
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Collaborative JS
How to build a collaborative browser-based editor (and why)
Ben Foxall
August 10, 2016
More Decks by Ben Foxall
See All by Ben Foxall
Web Sites & Fairy Lights
benfoxall
0
140
Making Simple Things
benfoxall
2
280
Simpler Things
benfoxall
0
1.9k
Using Browsers to Visualise Data
benfoxall
0
96
Serving Data From Browsers
benfoxall
0
85
Building multi-device interfaces with the web
benfoxall
1
190
Other Decks in Technology
See All in Technology
就職⽀援サービスにおけるキャリアアドバイザーのシフトスケジューリング
recruitengineers
PRO
1
150
白金鉱業Meetup_Vol.24_「AIエージェントは分けるほど良い」は本当か? / Is it true that “the more you divide AI agents, the better”?
brainpadpr
1
400
ルールやカスタム機能、どう活かす?ハンズオンで体感するIBM Bobの出力コントロール
muehara
1
170
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
620
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
150
RAG を使わないという選択肢
tatsutaka
1
250
FinOps × AIエージェントで実現する コストインシデントの自動調査
oasis1994liveforever
0
150
ACE-Step-1.5で見る 音楽生成AIのしくみと“破綻だけ直す”Retake機能の開発【zennfes spring 2026 登壇資料】
personabb
1
500
アジャイルな経理と Claude Code と経営の未来
kawaguti
PRO
3
130
LLMにもCAP定理があるという話
harukasakihara
0
390
2026TECHFRESH畢業分享會 - Lightning Talk - E起 See See : 電商推薦讀心術? 數據說了算
line_developers_tw
PRO
0
1.1k
新しいVibe Codingと”自走”について
watany
6
330
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
340
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
Technical Leadership for Architectural Decision Making
baasie
3
410
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
71
40k
Claude Code のすすめ
schroneko
67
230k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
It's Worth the Effort
3n
188
29k
Paper Plane (Part 1)
katiecoart
PRO
0
9k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
620
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Transcript
HELLO! I'm @benjaminbenben!
I work at @Pusher
None
I co-organise @JSOxford
None
I've not really said this stuff yet 1. Tell me
if we've been here too long 2. I'd be happy (and sorry) if you tell me this is rubbish
Live coding across all the things
Live coding across all the things
How to build a collaborative browser-based editor (and why)
䡿 Browser-based editors
None
side note - not just frontend
None
cojs.co
!
/
/ 䡿 The challenges
None
The challenges —Making a textarea feel nice —Showing content —Code
transpilation —External modules —Not breaking things
/ 䡿 The challenges Making a textarea feel nice
Web based code editors (maybe don't write one yourself) —Ace
Editor —Monaco —CodeMirror —~Atom~
None
Integration with our textarea CodeMirror.fromTextArea(source)
…tonnes more stuff
/ 䡿 The challenges Showing content <iframe id="target" href="/mypage"></iframe> (normal
answer: host it somewhere) !
Option 1.
"Upload" to ServiceWorker Web page → Service Worker → Network
hmmmmm —trendy —cool —persistant urls —overkill possibly —support is …
positive? —really cool
Option 2.
Data URIs
data:[<mediatype>][;base64],<data>
data:text/html,<h1>Hello! !
iframe.src = 'data:text/html;charset=utf-8,'+ '%3Cbody%3E%3Cscript%3E' + encodeURI(source.value) + '%3C/script%3E'
hmmm —lack of error handling —length limitations —random encoding issues
—restrictions…
None
Option 3.
Blobs new Blob(blobParts[, options])
b = new Blob(['…'], {type: 'text/html'})
b = new Blob(['…'], {type: 'text/html'}) url = URL.createObjectURL(b) //
"blob:https%3A/…/2084018…ab3a2cec02" // later URL.revokeObjectURL(url) !
var blob = generate(source.value) URL.revokeObjectURL(target.src) iframe.src = URL.createObjectURL(blob)
hmmm! —not stored on the stack —safe, and lots of
control —sounds cool
/ 䡿 The challenges Code transpilation
ES2015 const hey = (you) => console.log(`HELLO ${you}`) !
Tracuer Babel Bublé
All pretty cool, though personally ♥Bublé
Bublé —inspired by Babel —no shims / polyfills —compact transforms
only —less extensibility —fast —Nice one, Rich Harris
buble.transform(source.value).code
/ 䡿 The challenges External modules
// commonjs const utils = require('utils') utils.say('yeah!') // ES2015 modules
import {say} from 'utils' say('yeah!')
bundling !
Webpack Browserify Rollup
All pretty cool, though… ♥Rollup
Rollup —embracing ES2015 modules —minimal code-rewriting —tree shaking —d3, THREE.js
Rollup —embracing ES2015 modules —minimal code-rewriting —tree shaking —d3, THREE.js
—Seriously, Rich Harris you're the best
rollup.rollup({ entry: '__main__', plugins:[ { resolveId: (i) => i, load:
(id) => { if(id == '__main__') return source.value return fetch('/module/' + id + '.js') } } ] }).then(bundle => bundle.generate({ format: 'iife' }).code )
/ 䡿 The challenges Not breaking things
for(var i = 99; i > 0; i++) { console.log(`${i}
bottles of beer`) }
jsbin/loop-protect Super props, Remy Sharp loopProtect(`for(var i = 99; i
> 0; i++) { console.log(\`${i} bottles of beer\`) }`)
{;loopProtect.protect({ line: 1, reset: true }); for(var i = 99;
i > 0; i++) { if (loopProtect.protect({ line: 1 })) break; console.log(`${i} bottles of beer`) } !
/
/ 䡿 Why
Closing the loop
Closing the loop change, save, tab, ftp, wait, tab, refresh
Uploading stuff to a server
Closing the loop change, save, tab, refresh Local development
Closing the loop change, save Live reload+
Closing the loop change In place editing
This is a good thing
/ 䡿 Why Multi Device Development Experiments
/1 Collaboration
None
/2 Broadcast
/2.1 (Broadcast) For development
/2.2 (Broadcast) For talk-workshops
/3 Social inspired development
/
/ demo? let's build a "musical instrument"
People & user experience are the difficult things (so let's
focus on them)
Thank you, I'm @benjaminbenben (also, right here)