I am having bad performance scores with the Google Lighthouse score with Prismic.
Mainly the issues are "Remove unused JavaScript", "Preconnect to required origins" and "Serve static assets with an effecient cache policy".
One of the reasons for this is the toolbar script that exists on your page. At the moment the only solution to downsize the JS is to remove the script. You can do it if you want to reach a better score, but this is not good idea because this completely disables the Previews on your project .
We have plans on doing a feature that only injects the script when the a Preview session is
initialized. But this is only a plan and we’re not actively developing it right now. If this changes we’ll inform everyone in our blog and forum!
[UPDATE] For now one of the solutions is to still remove the toolbar, but, we're currently working on a version of the Toolbar that will greatly reduce its javascript payload (from 110kb to 10kb). But for the moment, these are some things you can do to improve performance:
Again, don't load the Prismic toolbar (using the Nuxt Module it's about setting preview: false), this will help you with the performance but you'll opt-out of the preview feature.
Load the toolbar script programmatically, even though is not recommended because you'll have to manually part of what the toolbar script is supposed to do (look at the preview token the writing room gives you, parse it, set the preview cookie, load the script according to that)
Just a quick update. The team worked hard to split the code for the toolbar so that it only loads the full preview script for logged in Prismic users. This should greatly help your lighthouse score
Old: 120kB for everyone New: 14kB for everyone + additional 130kB if detected as a logged in member of the Prismic repo / in a preview session.