diff --git a/Examples/ServiceWorker/index.html b/Examples/ServiceWorker/index.html
new file mode 100644
index 00000000..59796e99
--- /dev/null
+++ b/Examples/ServiceWorker/index.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/ServiceWorker/index.js b/Examples/ServiceWorker/index.js
new file mode 100644
index 00000000..26033734
--- /dev/null
+++ b/Examples/ServiceWorker/index.js
@@ -0,0 +1,51 @@
+/* global Y, Quill */
+
+// initialize a shared object. This function call returns a promise!
+
+Y({
+ db: {
+ name: 'memory'
+ },
+ connector: {
+ name: 'websockets-client',
+ room: 'ServiceWorkerExample'
+ },
+ sourceDir: '/bower_components',
+ share: {
+ richtext: 'Richtext' // y.share.richtext is of type Y.Richtext
+ }
+}).then(function (y) {
+ window.yQuill = y
+
+ // create quill element
+ window.quill = new Quill('#quill', {
+ modules: {
+ formula: true,
+ syntax: true,
+ toolbar: [
+ [{ size: ['small', false, 'large', 'huge'] }],
+ ['bold', 'italic', 'underline'],
+ [{ color: [] }, { background: [] }], // Snow theme fills in values
+ [{ script: 'sub' }, { script: 'super' }],
+ ['link', 'image'],
+ ['link', 'code-block'],
+ [{list: 'ordered' }]
+ ]
+ },
+ theme: 'snow'
+ });
+ // bind quill to richtext type
+ y.share.richtext.bind(window.quill)
+})
+
+if ('serviceWorker' in navigator) {
+ navigator.serviceWorker.register('./yjs-service-worker.js').then(function(registration) {
+ // Registration was successful
+ console.log('Yjs ServiceWorker registration successful with scope: ', registration.scope)
+ registration.active.postMessage('hi sw')
+ addEventListener('message', function () {console.log.apply(console, ['host received:'].concat(arguments))}, true)
+ }).catch(function(err) {
+ // registration failed :(
+ console.log('Yjs ServiceWorker registration failed: ', err)
+ });
+}
\ No newline at end of file
diff --git a/Examples/ServiceWorker/yjs-service-worker.js b/Examples/ServiceWorker/yjs-service-worker.js
new file mode 100644
index 00000000..acd427eb
--- /dev/null
+++ b/Examples/ServiceWorker/yjs-service-worker.js
@@ -0,0 +1,23 @@
+importScripts(
+ '/bower_components/yjs/y.js',
+ '/bower_components/y-memory/y-memory.js',
+ '/bower_components/y-indexeddb/y-indexeddb.js',
+ '/bower_components/y-websockets-client/y-websockets-client.js'
+)
+
+Y({
+ db: {
+ name: 'memory'
+ },
+ connector: {
+ name: 'websockets-client',
+ room: 'ServiceWorkerExample',
+ options: { jsonp: false }
+ }
+}).then(function (y) {
+ console.log('y sw init')
+})
+
+addEventListener('message', function () {
+ console.log.apply(console, ['sw received:'].concat(arguments))
+}, true)
\ No newline at end of file