New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

astro-remove-whitespace

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-remove-whitespace

Astro integration that removes whitespace between HTML tags in build output

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by300%
Maintainers
0
Weekly downloads
 
Created
Source

Astro Remove Whitespace Plugin

A simple Astro Plugin that removes unnecessary whitespace between HTML tags in your build output.

Background

Originally created by Utsubo, a creative studio based in Japan, to optimize their web projects. We noticed that Astro's build process preserved whitespace between closing tags, which added unnecessary bytes to the final bundle. This plugin solves that issue by cleaning up the HTML output post-build.

Features

  • Removes whitespace between HTML tags in build output
  • Preserves source code readability
  • Runs automatically after build completion
  • Minimal configuration required
  • Maintains other spacing and formatting
  • Processes all HTML files in build directory recursively

Installation

npm install astro-remove-whitespace

Usage

Add the plugin to your astro.config.mjs:

import removeTagWhitespace from 'astro-remove-whitespace';

export default defineConfig({
  integrations: [
    removeTagWhitespace()
  ],
});

Before and After

Before:

</g> </g> </svg> </div> </button>

After:

</g></g></svg></div></button>

How It Works

The plugin hooks into Astro's build process using the astro:build:done hook. After the build is complete, it:

  1. Recursively finds all HTML files in your build directory
  2. Removes whitespace between closing tags using regex
  3. Preserves other formatting and spacing
  4. Writes the optimized content back to the files

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Credits

Created and maintained by Utsubo - A Technology-First creative studio.

Keywords

FAQs

Package last updated on 30 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc