# Service worker: The script has an unsupported MIME type ('text/html')

**URL:** <https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941>\
**Category:** Developers\
**Created:** [July 16, 2021, 4:44pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941 "2021-07-16T16:44:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [July 16, 2021, 4:44pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/1 "2021-07-16T16:44:29Z")

</div>

Is there anything particular which needs to be done to configure the IC to serve correctly a service worker script?

I get following error:

> The script has an unsupported MIME type (‘text/html’).  
> service worker error DOMException: Failed to register a ServiceWorker for scope (‘[https://iey7l-kaaaa-aaaah-qadoa-cai.ic0.app/](https://iey7l-kaaaa-aaaah-qadoa-cai.ic0.app/)’) with script (‘[https://iey7l-kaaaa-aaaah-qadoa-cai.ic0.app/sw.js](https://iey7l-kaaaa-aaaah-qadoa-cai.ic0.app/sw.js)’): The script has an unsupported MIME type (‘text/html’)

[Link to app](https://iey7l-kaaaa-aaaah-qadoa-cai.ic0.app/)

 ![Capture d’écran 2021-07-16 à 18.44.40](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/e/e9190b5c8e74263e5abe6bdbf584ef892f812f9e.jpeg)

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 16, 2021, 5:17pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/2 "2021-07-16T17:17:35Z")

</div>

The issue is that ic0.app is already registering a serviceworker. Try accessing the site through `raw.ic0.app`

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [July 16, 2021, 5:33pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/3 "2021-07-16T17:33:20Z")

</div>

Thanks, it solves the issue.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [July 17, 2021, 11:06am UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/4 "2021-07-17T11:06:36Z")

</div>

Btw., if I may, what’s `raw` or what’s the difference, beside the sw, between with and without `raw`?

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 17, 2021, 4:56pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/5 "2021-07-17T16:56:43Z")

</div>

That’s it, really. Assets delivered over ic0.app are mediated by a service worker that checks that they are all certified assets before loading them.

The use case is that a malicious node responding to a query call for an asset could send a falsified response, messing with your application. A certified asset comes with a certificate that is is essentially a merkel tree, signed using our chain key consensus mechanism. That way, you can get a fast query from a single node and trust the signature, even if you don’t trust the node.

That said, the UX of the service worker is definitely slower and limiting, and the operations team is working on an alternate way to achieve the same level of trust through other means

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [July 17, 2021, 5:13pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/6 "2021-07-17T17:13:13Z")

</div>

Thank you for the explanation 🙏 All clear.

Glad to hear there aren’t other differences. As we don’t need that trust level with our app for the time begin, I’ll then continue with `raw`. The boot time performance boost is quite impressive.

---

<div class="post-metadata">

**Author:** ![quinto](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/quinto/32/26369_2.png) [@quinto](https://forum.dfinity.org/u/quinto)\
**Post date:** [July 17, 2021, 5:48pm UTC](https://forum.dfinity.org/t/service-worker-the-script-has-an-unsupported-mime-type-text-html/5941/7 "2021-07-17T17:48:08Z")

</div>

> [@anon74414410](#):
>
> the UX of the service worker is definitely slower and limiting

I wonder if the service worker can make use of local storage and load certified data from cache if their hashes didn’t change. That will significantly speed up HTML5 apps when “Add to Homescreen” on mobile phones.
