All Projects → coderaiser → Minify

coderaiser / Minify

Licence: mit
Minifier of js, css, html and img

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Minify

Pythonalgorithms
All Algorithms implemented in Python 3
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Customizer
Kanboard - Customizer adds GUI for logo, favicon and themes
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Facebook
📨 Facebook Notifications Channel for Laravel
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Monk gui
A Graphical user Interface for deep learning and computer vision over Monk Libraries
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Dev Folio
🔥 A collection of Free Portfolio templates for developers.
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Axolotl
A Signal compatible cross plattform client written in Go and Vuejs
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Git Url Parse
✌️ A high level git url parser for common git providers.
Stars: ✭ 119 (-0.83%)
Mutual labels:  hacktoberfest
Client
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Newsboat
An RSS/Atom feed reader for text terminals
Stars: ✭ 1,798 (+1398.33%)
Mutual labels:  hacktoberfest
Tech Companies In Nepal
List of tech companies based or working in Nepal. 🇳🇵
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Angular Open Source Starter
This is a starter project for creating open-source libraries for Angular. It is a full fledged Angular workspace with demo application and easy library addition. It is designed to be used for open-sourcing libraries on Github and has everything you'd need ready for CI, code coverage, SSR testing, StackBlitz demo deployment and more.
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Wp Graphql Yoast Seo
This is an extension to the WPGraphQL plugin for Yoast SEO
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Vue Select Image
✅ Vue 2.x component for selecting image from list
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Sudoku Solver
GUI Sudoku Solver using Pygame
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
React Tweet Embed
component that you supply tweet id and you'll get a tweet embed back, nothing more
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Tsuru Dashboard
Web dashboard for tsuru PaaS.
Stars: ✭ 119 (-0.83%)
Mutual labels:  hacktoberfest
Lru Cache Node
A lighting fast cache manager for node with least-recently-used policy.
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Yii2 Jui
Yii 2 JQuery UI extension.
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Vscode Verilog Hdl Support
Verilog HDL/SystemVerilog/Bluespec SystemVerilog support for VS Code
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest
Ngx Cookieconsent
Cookie 🍪 Consent module for Angular.
Stars: ✭ 120 (+0%)
Mutual labels:  hacktoberfest

Minify License Dependency Status Build Status NPM version Coverage Status

Minify - a minifier of js, css, html and img files. To use minify as middleware try Mollify.

Install

npm i minify -g

How to use?

CLI

The bash command below creates a code snippet saved as "hello.js".

Simply copy + paste the code starting with cat, including the EOT on the last line, and press .

$ cat << EOT > hello.js
const hello = 'world';

for (let i = 0; i < hello.length; i++) {
    console.log(hello[i]);
}
EOT

Use the command minify followed by the path to and name of the js file intended to be minified. This will minify the code and output it to the screen.

$ minify hello.js
const hello="world";for(let l=0;l<hello.length;l++)console.log(hello[l]);

You can capture the output with the following:

$ minify hello.js > hello.min.js

Code Example

minify can be used as a promise:

const minify = require('minify');
const options = {
    html: {
        removeAttributeQuotes: false,
        removeOptionalTags: false,
    },
};

minify('./client.js', options)
    .then(console.log)
    .catch(console.error);

Or with async-await and try-to-catch:

import minify from 'minify';
import tryToCatch from 'try-to-catch';
const options = {
    html: {
        removeAttributeQuotes: false,
        removeOptionalTags: false,
    },
};

const [error, data] = await tryToCatch(minify, './client.js', options);

if (error)
    return console.error(error.message);

Options

The options object accepts configuration for html, css, js, and img like so:

const options = {
    html: {
        removeAttributeQuotes: false,
    },
    css: {
        compatibility: '*',
    },
    js: {
        ecma: 5,
    },
    img: {
        maxSize: 4096,
    },
};

Full documentation for options that each file type accepts can be found on the pages of the libraries used by minify to process the files:

Minify sets a few defaults for HTML that may differ from the base html-minifier settings:

  • removeComments: true
  • removeCommentsFromCDATA: true
  • removeCDATASectionsFromCDATA: true
  • collapseWhitespace: true
  • collapseBooleanAttributes: true
  • removeAttributeQuotes: true
  • removeRedundantAttributes: true
  • useShortDoctype: true
  • removeEmptyAttributes: true
  • removeEmptyElements: false
  • removeOptionalTags: true
  • removeScriptTypeAttributes: true
  • removeStyleLinkTypeAttributes: true
  • minifyJS: true
  • minifyCSS: true

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].