Gatsby Plugin for No-JavaScript Static Sites

0.13.2 · active · verified Sun Apr 19

gatsby-plugin-no-javascript-utils is a Gatsby plugin designed to assist in generating purely static sites with minimal to no client-side JavaScript. It currently ships as version 0.13.2, which supports Gatsby versions 2 through 5, indicating a stable but relatively slow release cadence, typical for plugins that modify core build outputs rather than introduce new features. Its primary differentiator is its focus on stripping out various JavaScript-related artifacts that Gatsby typically includes by default, such as script tags, preload links for scripts and page data, JavaScript sourcemaps, and client-side routing announcers. Additionally, it offers options to remove generator meta tags, data attributes from head elements (like `data-react-helmet`), and convert inline `<style data-href>` tags to external `<link>` tags for improved caching and smaller HTML files. This makes it ideal for highly SEO-sensitive sites or those targeting extremely lightweight builds where JavaScript is entirely optional or handled externally.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to add the plugin to `gatsby-config.js` and configure its main options to achieve a truly JavaScript-free Gatsby build, optimizing for minimal HTML output and enhanced caching.

// In your gatsby-config.js
module.exports = {
  siteMetadata: {
    title: 'My Static Blog',
    description: 'A website with no JavaScript.',
  },
  polyfill: false, // Often disabled when removing JS
  plugins: [
    // Ensure this plugin is placed last to guarantee all scripts are removed
    // and other modifications are applied after other plugins have run.
    {
      resolve: 'gatsby-plugin-no-javascript-utils',
      options: {
        noScript: true, // Default: true - Removes all scripts and preload links
        noSourcemaps: true, // Default: true - Disables JS sourcemap generation
        removeGeneratorTag: true, // Default: true - Removes Gatsby generator meta tag
        removeHeadDataAttrs: true, // Default: true - Removes data-react-helmet and data-gatsby-head attrs
        noInlineStyles: true, // Default: false - Replaces <style data-href> with <link> tags
        removeGatsbyAnnouncer: true // Default: false - Removes accessibility announcer div
      }
    },
  ],
};

view raw JSON →