{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-09-30T09:11:22Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2673,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_javascript","title":"JavaScript","uri":"https:\/\/zotonic.com\/id\/2673"},"seq":3},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2718,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_cotonic","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/2718"},"seq":4},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2719,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_web_workers","title":"Web Workers","uri":"https:\/\/zotonic.com\/id\/2719"},"seq":5}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2725,"is_a":["text","documentation","reference","cotonic_reference"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2725"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cotonic_workers","page_url":{"en":"https:\/\/zotonic.com\/cotonic\/workers","x-default":"https:\/\/zotonic.com\/cotonic\/workers"},"preview_url":null,"resource":{"version":13,"pivot_location_lat":null,"title":"Workers","is_authoritative":true,"body":"<a name=\"workers\"><\/a>\n\n            <p>\n            Cotonic uses Web Workers which all run in separate calling context. This\n            means that they will not block the main user interface thread. They are\n            also truly isolated from each other. This means that a crash or another\n            kind of problem in worker A can&#39;t crash worker B.\n            <\/p>\n\n            <p>\n            You can run whatever code you like in workers, with some exceptions. You\n            can&#39;t access the DOM, and a lot of things from the window object. This also\n            makes them more secure because you don&#39;t have to worry that worker code\n            from an external resource can steal the a credit-card number entered\n            somewhere in the DOM tree.\n            <\/p>\n\n            <p>\n            Cotonic adds a MQTT like publish subscribe mechanism to the standard javascript\n            web worker api. This makes it easy for web workers to communicate with each other.\n            <\/p>\n\n<pre>\n\/\/ worker-a\n&quot;use strict&quot;;\n\nself.subscribe(&quot;some\/topic&quot;, function(message) {\n    self.publish(&quot;model\/ui\/update&quot;, &quot;&lt;p&gt;Worker A got message&lt;\/p&gt;&quot;)\n});\n\nself.publish(&quot;model\/ui\/insert&quot;, &quot;&lt;p&gt;Worker A started&lt;\/p&gt;&quot;);<\/pre>\n\n<pre>\n\/\/ worker-b\n&quot;use strict&quot;;\n\nself.subscribe(&quot;some\/topic&quot;, function(message) {\n    self.publish(&quot;model\/ui\/update&quot;, &quot;&lt;p&gt;Worker B got message&lt;\/p&gt;&quot;)\n});\n\nself.publish(&quot;model\/ui\/insert&quot;, &quot;&lt;p&gt;Worker B started&lt;\/p&gt;&quot;);<\/pre>\n\n\n<pre>\nlet worker_a = cotonic.spawn(&quot;worker-a.js&quot;, [1, 2]);\nlet worker_a = cotonic.spawn(&quot;worker-b.js&quot;);\n\ncotonic.broker.publish(&quot;some\/topic&quot;, &quot;hello workers!&quot;);\n<\/pre>\n\n            ","slug":"workers","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"09cdd7f0f86083be0cc56213be6a85eed918dbcc1f25cd5f20d45d59552fa7fb","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":2722,"is_a":["meta","category"],"name":"cotonic_reference","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/cotonic_reference"},"doc_source_path":"index.html","publication_start":"2026-09-30T09:11:22Z","page_path":"\/cotonic\/workers","github_url":"https:\/\/github.com\/cotonic\/cotonic\/blob\/master\/index.html","pivot_location_lng":null,"doc_source_kind":"cotonic","name":"doc_cotonic_workers","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2026-09-30T09:11:22Z","uri":null,"doc_source_anchor":"workers","doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f88cc928b997d10f7f19e6bd0ede80e1c8c619bc","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-09-30T10:06:59Z","title_slug":"workers"},"uri":"https:\/\/zotonic.com\/id\/2725","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2725"}},"status":"ok"}