# Serve prismic.js gzipped

**URL:** <https://community.prismic.io/t/serve-prismic-js-gzipped/4299>\
**Category:** Developing with Prismic\
**Tags:** product-feature-idea, javascript\
**Created:** [February 26, 2021, 8:26pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299 "2021-02-26T20:26:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![teamgi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/teamgi/32/2611_2.png) [@teamgi](https://community.prismic.io/u/teamgi)\
**Post date:** [February 26, 2021, 8:26pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/1 "2021-02-26T20:26:19Z")

</div>

I noticed that [https://static.cdn.prismic.io/prismic.js](https://static.cdn.prismic.io/prismic.js) is not being served using any compression. Can you please change this to serve it compressed. My request headers are set to accept gzip. Google Lighthouse is complaining about this, not to mention that we are wasting user's bandwidth.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [March 1, 2021, 2:20pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/2 "2021-03-01T14:20:58Z")

</div>

Hi Team,

Thanks for the feedback.

I've passed this to devs so they can see this idea. Hopefully they'll find time to do this, I'll also find out why this wasn't done already.

Thanks.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [March 1, 2021, 3:19pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/5 "2021-03-01T15:19:13Z")

</div>

Hi again,

It seems that [https://static.cdn.prismic.io/prismic.js](https://static.cdn.prismic.io/prismic.js) is already gzipped. You can test this here: [https://www.giftofspeed.com/gzip-test/](https://www.giftofspeed.com/gzip-test/)

Thanks.

---

<div class="post-metadata">

**Author:** ![teamgi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/teamgi/32/2611_2.png) [@teamgi](https://community.prismic.io/u/teamgi)\
**Post date:** [March 1, 2021, 3:46pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/6 "2021-03-01T15:46:48Z")

</div>

OK thanks for looking into this. For some reason while running multiple lighthouse tests, sometimes it would come back complaining about prismic.js not being compressed. When analyzing the network tab I could confirm that it was not compressed. But then I tried again and it was compressed. So I'm not sure what is going on. Seems to be an intermittent issue.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [March 1, 2021, 3:53pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/7 "2021-03-01T15:53:25Z")

</div>

Strange. Next time you see this can you take a screenshot of it in lighthouse or in the network tab so I can investigate further?

Thanks.

---

<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:** [March 4, 2021, 11:12am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/8 "2021-03-04T11:12:49Z")

</div>

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, 5:08pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/9 "2021-12-09T17:08:32Z")

</div>



---

<div class="post-metadata">

**Author:** ![digando](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@digando](https://community.prismic.io/u/digando)\
**Post date:** [January 13, 2022, 7:39am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/10 "2022-01-13T07:39:31Z")

</div>

Same problem in our SEO tools, sometimes there are no warnings and sometimes the tools recognize that the prismic.js is not compressed. Any new findings here?

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [January 13, 2022, 9:44am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/11 "2022-01-13T09:44:31Z")

</div>

Hi Alexander,

Welcome to the community!

[https://static.cdn.prismic.io/prismic.js](https://static.cdn.prismic.io/prismic.js) is already gzipped. You can test this here: [https://www.giftofspeed.com/gzip-test/](https://www.giftofspeed.com/gzip-test/)

Thanks.

---

<div class="post-metadata">

**Author:** ![digando](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@digando](https://community.prismic.io/u/digando)\
**Post date:** [January 13, 2022, 9:57am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/12 "2022-01-13T09:57:46Z")

</div>

Hi Phil, thanks for your answer. It's funny that this test always passes. Looks like there is an issue that sometimes the gzip compression is broken. Lighthouse tests and different SEO tools shows that it's not that reliable.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [January 13, 2022, 11:20am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/13 "2022-01-13T11:20:45Z")

</div>

Are you sure you're using the `.cdn` attribute?

---

<div class="post-metadata">

**Author:** ![digando](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@digando](https://community.prismic.io/u/digando)\
**Post date:** [January 13, 2022, 12:01pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/14 "2022-01-13T12:01:39Z")

</div>

Yes, we are using it!

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [January 13, 2022, 12:46pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/15 "2022-01-13T12:46:18Z")

</div>

It's strange, maybe it's not being recognised by the tools correctly. I'll pass this information to the team.

---

<div class="post-metadata">

**Author:** ![digando](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@digando](https://community.prismic.io/u/digando)\
**Post date:** [January 13, 2022, 12:53pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/16 "2022-01-13T12:53:11Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![kyle2](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kyle2](https://community.prismic.io/u/kyle2)\
**Post date:** [April 8, 2022, 8:47am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/17 "2022-04-08T08:47:17Z")

</div>

Any update on this?

---

<div class="post-metadata">

**Author:** ![kyle2](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kyle2](https://community.prismic.io/u/kyle2)\
**Post date:** [April 8, 2022, 9:04am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/18 "2022-04-08T09:04:28Z")

</div>

Perhaps also the script fetch can be prevented altogether.

If this is for preview mode only I'm guessing we can just do something like

```auto
import { FC } from 'react'
import { API } from '../project/api'
import Script from 'next/script' // we need this to make JSX compile

type ComponentType = {}

const PrismicScript: FC<ComponentType> = ({}) => {
  return API.storage.getItemSync('io.prismic.preview') ? (
      <Script
        src={`https://static.cdn.prismic.io/prismic.js?new=true&repo=x`}
      />
  ) : null
}

export default PrismicScript

```

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 8, 2022, 4:33pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/19 "2022-04-08T16:33:02Z")

</div>

Hi Kyle,

No update on why this isn't appearing as gzipped.

For your suggestion, I'm going to check with the team if this works. But off the top of my head, this would stop the edit button from appearing (Although it's not working right now in statically deployed next.js websites anyway).

Thanks.

---

<div class="post-metadata">

**Author:** ![kyle2](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kyle2](https://community.prismic.io/u/kyle2)\
**Post date:** [April 8, 2022, 6:20pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/20 "2022-04-08T18:20:42Z")

</div>

Since it's a backend cookie on prismic, it didn't work. However this did

```auto
// PrismicWrapper.tsx

import { FC, useEffect, useState } from 'react'
import { PrismicPreview } from '@prismicio/next'
import { repositoryName } from 'prismicio'

type ComponentType = {}

const PrismicScript: FC<ComponentType> = ({ children }) => {
  const [isActive, setIsActive] = useState<boolean>(false)
  useEffect(() => {
    fetch('/api/prismic')
      .then((r) => r.text())
      .then((res) => {
        if (res) {
          setIsActive(true)
        }
      })
  }, [])
  if (isActive) {
    return (
      <PrismicPreview repositoryName={repositoryName}>
        {children}
      </PrismicPreview>
    )
  }

  return <>{children}</>
}

```

```auto
//api/prismic

import { linkResolver, createClient } from 'prismicio'
import { setPreviewData, redirectToPreviewURL } from '@prismicio/next'
import { NextApiRequest, NextApiResponse } from 'next'
import nookies from 'nookies'
export default async (req: NextApiRequest, res: NextApiResponse) => {
  const data = nookies.get({ req })
  if (data.__next_preview_data) {
    res.send('1')
  } else {
    res.send('')
  }
}

```

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 11, 2022, 8:46am UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/21 "2022-04-11T08:46:03Z")

</div>

Thanks for sharing your workaround @kyle2 🙂

_Note for future users though, this will disable the edit button._

---

<div class="post-metadata">

**Author:** ![kyle2](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kyle2](https://community.prismic.io/u/kyle2)\
**Post date:** [April 25, 2022, 2:40pm UTC](https://community.prismic.io/t/serve-prismic-js-gzipped/4299/22 "2022-04-25T14:40:56Z")

</div>

Hey, I was just wondering - what is the "Edit button"? I'm not sure I've ever seen one, do you mean this? If so I still see it.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/e/e0ffe0684df99ee0c514b636428c32a90419f855.png)

[Next page](https://community.prismic.io/t/serve-prismic-js-gzipped/4299.md?page=2)
