knitr::opts_chunk$set( collapse = TRUE, comment = "", fig.path = "man/figures/README-", out.width = "100%" )
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, http://www27.cs.kobe-u.ac.jp/achieve/data/pdf/1198.pdf
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/
You can install the dev version of {minifyr}
with:
remotes::install_github("colinfay/minifyr")
NOTE: YOU WILL NEED NODEJS ON YOUR MACHINE
You'll need to run this once:
# Check node and npm are available minifyr::node_available() # Will install the node dependencies minifyr::minifyr_npm_install()
For now, all the Node functions are called with their default arguments.
minifyr_css_cleancss()
minifyr_css_crass()
minifyr_css_cssnano()
minifyr_css_csso()
minifyr_css_sqwish()
minifyr_css_yui()
minifyr_html_minifier()
minifyr_js_babel()
minifyr_js_gcc()
minifyr_js_terser()
minifyr_js_uglify()
minifyr_js_yuiy()
minifyr_json_jsonminify()
minifyr comes with a series of examples:
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.
echo "body { margin: 25px; background-color: rgb(240,240,240); font-family: arial, sans-serif; font-size: 14px; }" >> "test.css"
cat test.css
minifyr::minifyr_css_cleancss("test.css", "test2.css")
minifyr::minifyr_css_cleancss("test.css", "test2.css")
cat test2.css
Note that all minifiers do not minify the same way
minifyr::minifyr_css_crass("test.css", "test3.css")
minifyr::minifyr_css_crass("test.css", "test3.css")
cat test3.css
{bash, echo=FALSE}
rm test.css test2.css test3.css
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.