Web workercheatsheet
Web worker
Client
JSvar worker = new Worker('worker.js')worker.onmessage = function (message) { alert(JSON.stringify(message.data))})worker.postMessage('hello!')
Worker
JSself.onmessage = function (message) { ···}self.postMessage({ msg: 'hello' })
Message data
[MessageEvent]
JSbubbles: falsecancelBubble: falsecancelable: falseclipboardData: undefinedcurrentTarget: Workerdata: "Hello" ← the datadefaultPrevented: falseeventPhase: 0lastEventId: ""origin: ""ports: Array[0]returnValue: truesource: nullsrcElement: Workertarget: WorkertimeStamp: 1344821022383type: "message"