# Remove unused JS

**URL:** <https://community.prismic.io/t/remove-unused-js/4941>\
**Category:** Developing with Prismic\
**Tags:** javascript\
**Created:** [April 12, 2021, 6:22pm UTC](https://community.prismic.io/t/remove-unused-js/4941 "2021-04-12T18:22:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marina.selim](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@marina.selim](https://community.prismic.io/u/marina.selim)\
**Post date:** [April 12, 2021, 6:22pm UTC](https://community.prismic.io/t/remove-unused-js/4941/1 "2021-04-12T18:22:31Z")

</div>

When using Lighthouse / Google page speed insight it flags these scripts are unused

|…/node\_modules/prismic-javascript/dist/prismic-javascript.min.js | 6.2 KiB | 4.5 KiB  
|…/node\_modules/prismic-dom/dist/prismic-dom.min.js | 4.1 KiB | 2.9 KiB  
|…/node\_modules/fp-ts/lib/ReadonlyArray.js | 3.8 KiB | 2.6 KiB  
|…/node\_modules/superstruct/lib/index.es.js | 2.2 KiB | 1.7 KiB  
|…/node\_modules/prismic-javascript/node\_modules/cross-fetch/dist/browser-polyfill.js | 1.6 KiB | 1.4 KiB

Why are they loaded by the plugin if unsued ? Shouldn't they be removed ?

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [April 13, 2021, 3:05pm UTC](https://community.prismic.io/t/remove-unused-js/4941/2 "2021-04-13T15:05:45Z")

</div>

Hello @marina.selim welcome to the Community!

Which technology stack are you using? and what is the url of your site?  
I'd like to run lighthouse to see this on my end

---

<div class="post-metadata">

**Author:** ![marina.selim](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@marina.selim](https://community.prismic.io/u/marina.selim)\
**Post date:** [April 13, 2021, 3:46pm UTC](https://community.prismic.io/t/remove-unused-js/4941/4 "2021-04-13T15:46:50Z")

</div>

Thanks for answering

I use Gatsby with the gatsby-source-prismic plugin  
Here is the website : [https://calyxia.vercel.app/](https://calyxia.vercel.app/)

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [April 27, 2021, 3:51pm UTC](https://community.prismic.io/t/remove-unused-js/4941/5 "2021-04-27T15:51:17Z")

</div>

Hey @marina.selim,

I have an update about this topic.

To answer your original question, those modules are used for the preview functionality and currently can’t be removed to answer your original question. If you don't use previews in your project and don’t import any of the preview functions of the plugin, then it shouldn’t bring those dependencies into their production code.

In the upcoming new version of the plugin (V4), previews are a separate plugin, so it will be opt-in. Also, the dependencies are going to be reduced.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [May 3, 2021, 3:47pm UTC](https://community.prismic.io/t/remove-unused-js/4941/6 "2021-05-03T15:47:53Z")

</div>

closed on May 3, 2021, 3:47pm UTC as resolved,  flag & select 'Something Else' to reopen.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 4:20pm UTC](https://community.prismic.io/t/remove-unused-js/4941/7 "2021-12-09T16:20:24Z")

</div>

Opened on December 9, 2021, 4:20pm UTC


