Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ColinFay/minifyr
Wrapper around node-minify NodeJS module
https://github.com/ColinFay/minifyr
Last synced: 8 days ago
JSON representation
Wrapper around node-minify NodeJS module
- Host: GitHub
- URL: https://github.com/ColinFay/minifyr
- Owner: ColinFay
- License: other
- Created: 2020-05-07T20:33:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-19T15:05:10.000Z (over 1 year ago)
- Last Synced: 2024-08-13T07:14:55.238Z (4 months ago)
- Language: R
- Size: 539 KB
- Stars: 9
- Watchers: 5
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ColinFay/minifyr - Wrapper around node-minify NodeJS module (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# minifyr
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R-CMD-check](https://github.com/ColinFay/minifyr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ColinFay/minifyr/actions/workflows/R-CMD-check.yaml)> Extremely high-speed network infrastructures are becoming more and more popular in developed countries. However, we still face crowded and low-speed Wi-Fi environments on airport, cafe, international conference, etc. Especially, a network environment of mobile devices requires efficient usage of network bandwidth.
_Empirical Study on Effects of Script Minification and HTTP Compression for Traffic Reduction_,
The goal of `{minifyr}` is to provide a wrapper around the `node-minify` NodeJS module.
This package bundles the whole NodeJS minifiers, so that they can be run from R.
More background info at: [colinfay.me/node-r-package/](https://colinfay.me/node-r-package/)
## Installation
You can install the dev version of `{minifyr}` with:
``` r
remotes::install_github("colinfay/minifyr")
```__NOTE: YOU WILL NEED NODEJS ON YOUR MACHINE__
## Example
### Install the Node deps
You'll need to run this once:
```{r eval = FALSE}
# Check node and npm are available
minifyr::node_available()
# Will install the node dependencies
minifyr::minifyr_npm_install()
```### Note
For now, all the Node functions are called with their default arguments.
### Minifying CSS
+ [clean-css](https://github.com/jakubpawlowicz/clean-css), with `minifyr_css_cleancss()`
+ [crass](https://github.com/mattbasta/crass), with `minifyr_css_crass()`
+ [cssnano](https://github.com/cssnano/cssnano), with `minifyr_css_cssnano()`
+ [csso](https://github.com/css/csso), with `minifyr_css_csso()`
+ [sqwish](https://github.com/ded/sqwish), with `minifyr_css_sqwish()`
+ [yui](http://yui.github.io/yuicompressor/), with `minifyr_css_yui()`### Minifying HTML
+ [html-minifier](https://github.com/kangax/html-minifier), with `minifyr_html_minifier()`
### Minify JS
+ [babel-minify](https://github.com/babel/minify), with `minifyr_js_babel()`
+ [Google Closure Compiler](https://developers.google.com/closure/compiler/), with `minifyr_js_gcc()`
+ [terser](https://github.com/terser-js/terser), with `minifyr_js_terser()`
+ [uglify-js](https://github.com/mishoo/UglifyJS2), with `minifyr_js_uglify()`
+ [YUI Compressor](http://yui.github.io/yuicompressor/), with `minifyr_js_yuiy()`### Minify JSON
+ [jsonminify](https://github.com/babel/minify), with `minifyr_json_jsonminify()`
### Minifyr example
minifyr comes with a series of examples:
```{r}
library(minifyr)
minifyr_example("css")
minifyr_example("html")
minifyr_example("json")
minifyr_example("js")
```Note that files are copied to a tempfile so that you don't accidentally erase the original files.
### Example
```{bash}
echo "body {
margin: 25px;
background-color: rgb(240,240,240);
font-family: arial, sans-serif;
font-size: 14px;
}" >> "test.css"
``````{bash}
cat test.css
``````{r, include=FALSE}
minifyr::minifyr_css_cleancss("test.css", "test2.css")
``````{r, eval=FALSE}
minifyr::minifyr_css_cleancss("test.css", "test2.css")
``````{bash}
cat test2.css
```Note that all minifiers do not minify the same way
```{r, include=FALSE}
minifyr::minifyr_css_crass("test.css", "test3.css")
``````{r, eval=FALSE}
minifyr::minifyr_css_crass("test.css", "test3.css")
``````{bash}
cat test3.css
``````{bash, echo=FALSE}
rm test.css test2.css test3.css
```