Giter Club home page Giter Club logo

web-minify-helper's Introduction

Web minify helper!

Gitter chat dependencies Status

Let me help you minify css and js files automatically and easily!

This is only a shell script; it depends on bash shell, grep, curl and nodejs/npm.

It is based on clean-css, uglify-js and javascript-minifier.com/cssminifier.com.

Feel free to contribute to the project if you want!

Requirements

  • Bash shell
  • grep
  • curl
  • Node.js >= (4.0)

How to use?

$ git clone --recursive https://github.com/PeterDaveHello/web-minify-helper.git
$ cd web-minify-helper
$ npm install

First go to the target directory you want to minify, then run the script(path_of_script/minify.sh). Or you can pass the directory's path as a parameter to the script!

You may even place the script file (or make a link to it) under the $HOME/bin directory, allowing you to conveniently run this script from any directory!

Explanation

The script will scan all the directories under the current working directory, except path with '.git'.

Then, it will check all the js & css files to see if they already have a minified version (currently, it recognizes it by looking for a .min in the filename, before the file extension).

If the file does not have a minified version, it will minify it.

Furthermore, even if there is a minified version available, the script will compare the last modified time between the original file and its minified version. If the original one is newer than the minified one -- which means the minified file is older than the original -- then it will replace the old minified file with a new minified version!

web-minify-helper's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar kemayo avatar nbkhope avatar nwholloway avatar peterdavehello avatar renovate-bot avatar yhkuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

web-minify-helper's Issues

CSS minified output gives html with 301 Moved Permanently

I tried using the script to minify a css file, but the output was the following:

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
</body>
</html>

First, I went to the directory where my files are. Then, I ran the script ~/some/where/minify.sh using Bash v4.4.12.

Checker after minify

Each file need to be checked after minifying, avoid to get a empty file(network issue or other problem) or a file bigger than original one(already minified without .min in filename).

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Drop YUI Compressor

Since there is no new release since v2.4.8, it's more then 2 years, but v2.4.8 is incompatible with many javascript libraries(will thought them have syntax error), so should find another minifier to replace YUI compressor.

Can't minify file

I got the error message when I try to minify the https://github.com/sourcelair/xterm.js/blob/0.4/src/xterm.js
The error message shows as following:

$ ~/web-minify-helper/minify.sh --no-map
Scaning direcotry...
Finding js to be compressed under . ...
Compressing xterm.js ...
Parse error at xterm.js:419,24
    ev.stopPropagation[();
                        ^
SyntaxError: Unexpected token: punc ())
    at JS_Parse_Error.Object.defineProperty.get (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)
    at /home/sjfu/web-minify-helper/node_modules/uglify-js/bin/uglifyjs:384:39
    at time_it (/home/sjfu/web-minify-helper/node_modules/uglify-js/bin/uglifyjs:620:15)
    at /home/sjfu/web-minify-helper/node_modules/uglify-js/bin/uglifyjs:345:9
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
Parse error at xterm.js:419,25
SyntaxError: Unexpected token punc «;», expected arrow «=>»
Error
    at new JS_Parse_Error (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:1928:18)
    at js_error (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:1936:11)
    at croak (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:2589:9)
    at token_error (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:2597:9)
    at expect_token (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:2610:9)
    at arrow_function (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:2926:9)
    at maybe_assign (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:4164:20)
    at expression (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:4198:20)
    at subscripts (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:4024:24)
    at subscripts (eval at <anonymous> (/home/sjfu/web-minify-helper/node_modules/uglify-js-harmony/tools/node.js:28:1), <anonymous>:4015:20)
local compressor failed, now try to compress with javascript-/cssminifier.com

When I do cdnjs/cdnjs#10764, I can minify all the files in v0.0.2~v2.0.0 except v0.4 of xterm.js.
Could you help me fix this issue?
Thanks.

grep may not work properly under FreeBSD

Need to detect if gnu grep is installed and use it, or, rewrite to not use gnu grep only usage.

elif [ $(wc -l "$filename.$filetype" | awk '{print $1}') -ge 15 ] || [ $(grep -E $'^(\t|\ )' "$filename.$filetype" | wc -l) -ge 5 ]; then

    elif [ $(wc -l "$filename.$filetype" | awk '{print $1}') -ge 15 ] || [ $(grep -E $'^(\t|\ )' "$filename.$filetype"  | wc -l) -ge 5 ]; then
        do_min=1
    fi

gnu grep reference:
https://unix.stackexchange.com/questions/65603/how-to-make-gnu-grep-the-default-in-freebsd

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm uglify-es Unavailable

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • clean-css-cli ^4.1.11
  • uglify-es ^3.3.10
  • uglify-js ^3.4.6

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.