Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub

gatsby-plugin-zstd

Gatsby plugin for preparing zstd-compressed versions of assets.

/webpack-runtime-cde5506958f1afc4d89e.js

becomes

/webpack-runtime-cde5506958f1afc4d89e.js.zst

Requirements

This plugin will only generate the compressed files. To see them been served to the client, your Gatsby website should run on a production server that supports Zstd .zst-files. The Gatsby development server does not serve the compressed versions.

Installation

With npm:

npm install --save gatsby-plugin-zstd

Usage

In your gatsby-config.js file add:

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-zstd'
    }
  ]
}

By default, only css, html, js, svg, json and xml files are compressed, but you can override this with the extensions option.

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-zstd',
      options: {
        extensions: ['css', 'html', 'js', 'svg']
      }
    }
  ]
}

By default, files are compressed using the highest level of compression supported by zstd, but you can override this with the level option.

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-zstd',
      options: {
        level: 4
      }
    }
  ]
}

You can even place all the zstd-compressed files (only the zstd ones, the uncompressed ones will be saved in the public directory as usual) in a dedicated directory (ex. public/zstd):

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-zstd',
      options: {
        path: 'zstd'
      }
    }
  ]
}

License

Licensed under MIT.

NOTE: This plugin only generates output when run in production mode! To test, run: gatsby build && gatsby serve

© 2026 Gatsby, Inc.