Skip to content

Repository files navigation

minifyhtml

Minify HTML Documents

Description

Minifies HTML (no CSS or JavaScript yet) via the Rust minify-html crate (https://github.com/wilsonzlin/minify-html).

NOTE

Minifying CSS and JavaScript requires another Rust module with some features enabled in minify-html that doesn’t seem to work on arm64 Macs (yet). Ima figure it out and get that working at some point.

What’s Inside The Tin

The following functions are implemented:

  • minify: Minify UTF-8 HTML code

Installation

remotes::install_github("hrbrmstr/minifyhtml")

NOTE: To use the ‘remotes’ install options you will need to have the {remotes} package installed.

Usage

library(minifyhtml)
# current version
packageVersion("minifyhtml")
## [1] '0.1.0'
'<html xmlns="http://www.w3.org/1999/xhtml"><head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <!-- COMMENT --> <style> * { color: black; } </style> <title>TITTLE</title> </head> <body> <p> Some tex </p> <script> console.log("This is a console log message."); </script> </body></html>'->src
cat(minify(src))
## <html xmlns=http://www.w3.org/1999/xhtml><meta charset=UTF-8><meta content=width=device-width,initial-scale=1 name=viewport><style>* { color: black; }</style><title>TITTLE</title><body><p>Some tex</p><script>console.log("This is a console log message.");</script>
src<-httr::content(httr::GET("https://rud.is"), as="text")
cat(substr(src, 1, 300))
## <html xmlns="http://www.w3.org/1999/xhtml">## <head>## <meta charset="UTF-8"/>## <meta name="viewport" content="width=device-width, initial-scale=1"/>## <meta name="theme-color" content="#4575b4"/>## <!-- meta name="viewport" content="user-scalable=false" / -->## <meta name="wot-verification" content="682597b61
cat(substr(minify(src), 1, 300))
## <html xmlns=http://www.w3.org/1999/xhtml><meta charset=UTF-8><meta content=width=device-width,initial-scale=1 name=viewport><meta content=#4575b4 name=theme-color><meta content=682597b61c21873545ca name=wot-verification><meta content=ltsLJXWktlxKHpTw8xKoHsF2MnAjV9o7O0FmtGk1c_Y name=google-site-verif

minifyhtml Metrics

Lang# Files(%)LoC(%)Blank lines(%)# Lines(%)
Rust20.0278950.48100.0540.03
D200.192210.01520.2800.00
Rmd10.01320.00210.11320.23
R30.03300.0050.03310.22
JSON250.24250.0000.0000.00
TOML10.01130.0020.0100.00
C10.0140.0020.0120.01
SUM530.5082200.50920.50690.50

clock Package Metrics for minifyhtml

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

About

Minifies HTML (no CSS or JavaScript yet) via the Rust minify-html crate (<https://github.com/wilsonzlin/minify-html>)

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages