![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
email-minifier
Advanced tools
A well-tested email minifier based on TypeScript for browser and Node.js
EmailMinifier is a well-tested email minifier based on TypeScript for browser and Node.js
https://github.com/luckrnx09/email-minifier/assets/113882203/2f2ad00e-73d8-437e-b357-7505b9d9e78a
As a quick start, you can Try it online 🚀
HTMLMinifier is a great tool for compressing HTML. But email is different from HTML in many ways, compression of HTML is often not the best solution.
You can use the tool you like to install EmailMinifier:
npm
npm install email-minifier
yarn
yarn add email-minifier
pnpm
pnpm install email-minifier
For both browser and Node.js if you use ESM:
import { EmailMinifier } from 'email-minifier';
(async () => {
const emailBody = `<div class="hello"></div>`;
const options = {};
const result = await new EmailMinifier(emailBody).minify(options);
console.log(result);
})();
For Node.js only if you use CommonJS:
const { EmailMinifier } = require('email-minifier');
(async () => {
const emailBody = `<div class="hello"></div>`;
const options = {};
const result = await new EmailMinifier(emailBody).minify(options);
console.log(result);
})();
The minify()
method will returns a Promise with the shape as follow:
{
original: '', // the original email body string
minified: '', // minified email body string will be here, if no tasks ran, it'll be null
tasks: [] // all ran tasks when minify email body
}
All available properties for options
are as follows
Option | Description | Default |
---|---|---|
minifyIds | Minifiy id attributes used in style tags | true |
minifyClasses | Minifiy class attributes used in style tags | true |
minifyDatasets | Minifiy data-* attributes used in style tags | true |
removeUnusedAttrs | Remove custom attributes unused in style tags | false |
minifyStyles | Minifiy CSS content for all the style tags | true |
For removeUnusedAttrs
, if you want to remove the specific unused attributes, you can provide an array with RegExp
instances to match them.
For example:
const options = {
removeUnusedAttrs: [
new RegExp('custom-test-id') // Remove `custom-test-id` attributes if they not used in style tags
]
};
The following table shows the statistics in the Node.js environment
Original Size | Minified Size | Elapsed Time | |
---|---|---|---|
Holiday Cheer | 33.09kb | 32.36kb | 580.30ms |
Membership Discount | 104.00kb | 37.97kb | 93.61ms |
Movies for Christmas | 289.47kb | 58.30kb | 138.13ms |
The emails above are generated from unlayer.
See LICENSE
FAQs
A well-tested email minifier based on TypeScript for browser and Node.js
The npm package email-minifier receives a total of 0 weekly downloads. As such, email-minifier popularity was classified as not popular.
We found that email-minifier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.