Remove unused JS

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 ?

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

Thanks for answering

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

1 Like

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.

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