A collection of minimal, dependency-free, performance-focused utilities for improving and compressing code or data in modern web and edge environments.
Optimizers provides safe, auditable modules designed to make code smaller and faster without unsafe parsing or heavy dependencies. Each tool focuses on a single responsibility and runs without build steps or runtime polyfills.
Available modules:
-
is-dataset-minify — High-performance dataset optimizer for JSON, JSONL, and CSV.
-
is-google-tag — Optimizes Google Tag for async, non-blocking, privacy-safe loading.
-
is-html-minify — Safe HTML minifier that removes comments and collapses whitespace while preserving
<pre>,<textarea>,<script>, and<style>content.
-
is-minify — Safe, dependency-free JavaScript and CSS minifier for browser and Node.
-
is-prompt-minify — Compact large language model (LLM) prompts by removing redundancy, extra whitespace, and repeated phrases without altering meaning.
-
is-strip-ansi — Removes ANSI escape sequences (color codes, control characters) from strings safely.
All helpers are designed for use in:
- Browsers (ESM)
- Node.js / Deno / Bun
- Edge runtimes (Cloudflare Workers, Vercel Edge, etc.)
Each module has its own README.md, tests, and can be imported individually.
You can try each validator interactively in your browser:
- Dataset Optimizer Test
- Google Tag Demo
- html Minification Demo
- JS/CSS Minification Demo
- Prompt Minify Demo
- Strip ANSI Demo
Each page loads its respective module and allows interactive validation.
npm i @yvancg/optimizersor per-module packages when published
- No eval or dynamic code.
- No untrusted regular expressions.
- Deterministic output with consistent whitespace and comment removal.
- Safety first: Never execute or interpret arbitrary code during optimization.
- No dependencies: All logic is pure ESM JavaScript.
- Performance: Runs in O(n) time on typical input.
- Portability: Works the same in browser, Node, and edge runtimes.
- Transparency: Fully open-source, easy to audit.
import { optimizeDataset } from './is-dataset/dataset.js';
import { optimizeGTag } from './is-google-tag/gtag.js';
import { minifyHTML } from './is-html-minify/html.js';
import { minifyJS, minifyCSS } from './is-minify/minify.js';
import { promptMinify } from './is-prompt-minify/prompt.js';
import { stripAnsi } from './is-strip-ansi/strip.js';
console.log(generateDataset({ count: 3, format: 'jsonl', seed: 'demo' }));
// → '{"id":"...","text":"Lorem ipsum ..."}'
console.log(
optimizeDataset(
'[{"id":1,"Text":" Hello world "},{"id":1,"Text":"Hello world"}]',
{ format: 'json', keyCase: 'snake', dropDuplicateRows: true }
)
);
// → '[{"id":1,"text":"Hello world"}]'
console.log(optimizeGTag('<script src="https://www.googletagmanager.com/gtag/js?id=G-TEST"></script>'));
// → optimized, async, privacy-safe version of the tag
console.log(minifyHTML(`
<!-- comment -->
<div class="box">
<p> Hello world </p>
<pre> keep this </pre>
<script> const x = 1 + 2 </script>
</div>
`));
// → '<div class="box"><p>Hello world</p><pre> keep this </pre><script> const x = 1 + 2 </script></div>'
console.log(minifyJS('function x () { return 1 + 2 ; }'));
// → 'function x(){return 1+2;}'
console.log(minifyCSS('body { color : red ; }'));
// → 'body{color:red;}'
console.log(promptMinify('You are a helpful helpful AI assistant. Please please respond clearly clearly.'));
// → 'You are a helpful AI assistant. Please respond clearly.'
console.log(stripAnsi('\u001B[31mError:\u001B[0m invalid token'));
// → 'Error: invalid token'validators/
├─ .github/
│ ├─ workflows/
│ └─ FUNDING.yml
├─ LICENSE
├─ README.md
├─ SECURITY.md
├─ catalog.json
├─ is-dataset-minify/
├─ is-google-tag/
├─ is-html-minify/
├─ is-minify/
├─ is-prompt-minify/
├─ is-strip-ansi/
├─ bench/
└─ metrics/
- No dynamic code execution or new
Function()calls. - All regexes are tested for ReDoS safety.
- Produces deterministic minified output safe for sandboxed environments.
Pull requests for additional safe validators (e.g., IBAN, domain names, etc.) are welcome. Please maintain the following rules:
- Pure functions only (no side effects)
- No external dependencies
- 100% test coverage for new logic
- TypeScript or plain ESM JavaScript
Licensed under the MIT License — see LICENSE.
If you find this project useful, please consider sponsoring its continued maintenance and security audits.
You can sponsor this project through:
- GitHub Sponsors: https://github.com/sponsors/yvancg
- Or any link listed in
.github/FUNDING.yml
© 2025 Y Consulting LLC / Optimizers Project