optimizers

Optimizers

A collection of minimal, dependency-free, performance-focused utilities for improving and compressing code or data in modern web and edge environments.

Overview

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:

All helpers are designed for use in:

Each module has its own README.md, tests, and can be imported individually.

🔗 Live Demos (GitHub Pages)

You can try each validator interactively in your browser:

Each page loads its respective module and allows interactive validation.

Install

npm i @yvancg/optimizers

or per-module packages when published

API Guarantees

Design Principles

  1. Safety first: Never execute or interpret arbitrary code during optimization.
  2. No dependencies: All logic is pure ESM JavaScript.
  3. Performance: Runs in O(n) time on typical input.
  4. Portability: Works the same in browser, Node, and edge runtimes.
  5. Transparency: Fully open-source, easy to audit.

Example Usage

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'

Folder Structure

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/

Security Notes

Contributing

Pull requests for additional safe validators (e.g., IBAN, domain names, etc.) are welcome. Please maintain the following rules:

License

Licensed under the MIT License — see LICENSE.

Funding

If you find this project useful, please consider sponsoring its continued maintenance and security audits.

You can sponsor this project through:


© 2025 Y Consulting LLC / Optimizers Project