Sharing websocket across browser tabs?

After seeing this question, I’ve finally implemented sharing socket and added to my library a few days ago. It seems to work in most of browsers including even in IE6, but except Opera. For Opera, you may use regular checking instead of unload event. Check releated issue at https://github.com/flowersinthesand/portal/issues/21 ###Leaving a cookie Set cookie to … Read more

What can service workers do that web workers cannot?

Buksy’s answer is correct but in my opinion it does not answer the original question, namely: “What can service workers do that web workers cannot? Or vice versa?” There are fundamental differences in their lifecycle and the number of instances per origin you can have. In short: | Web Workers | Service Workers | |————–|————–|——————| … Read more

Accessing localStorage from a webWorker

Web workers only have access to the following: XMLHttpRequest Application Cache Create other web workers navigator object location object setTimeout method clearTimeout method setInterval method clearInterval method Performance object (mark,measure,now methods: caniuse?) IndexedDB API (see: caniuse?) importScripts method JSON Worker The window or parent objects are not accessible from a Web worker therefore you can’t … Read more

How to allow Web Workers to receive new data while it still performing computation?

Even though the Worker works on an other thread than the one of your main page, and can thus run continuously without blocking the UI, it still runs on a single thread. This means that until your sort algorithm has finished, the Worker will delay the execution of the message event handler; it is as … Read more

Is there a way to create out of DOM elements in Web Worker?

Alright, I did some more research with the information @Bergi provided and found the following discussion on W3C mailing list: http://w3-org.9356.n7.nabble.com/Limited-DOM-in-Web-Workers-td44284.html And the excerpt that answers why there is no access to the XML parser or DOM parser in the Web Worker: You’re assuming that none of the DOM implementation code uses any sort of … Read more

Web Workers – How To Import Modules

ES2015 modules in Workers are available in Safari and in Chromium browsers. If other browsers / versions are your target, you still need to use importScripts(). When available, you create a module-worker like this: new Worker(“worker.js”, { type: “module” }); See: https://html.spec.whatwg.org/#module-worker-example These are the bug-reports for each browser: Firefox: In development (almost done) šŸ›‘ … Read more

Making WebWorkers a safe environment

The current code (listed below) has been now in use in the Stackoverflow javascript chat room for a while and so far the toughest problem was Array(5000000000).join(“adasdadadasd”) instantly crashing some browser tabs for me when I was running the code executor bot. Monkeypatching Array.prototype.join seems to have fixed this and the maximum execution time of … Read more