2018-06-30 06:37:24 -04:00
|
|
|
# hyperbuild
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
A fast one-pass in-place HTML minifier written in C with advanced whitespace handling.
|
2018-10-25 07:54:54 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
Currently in beta, working on documentation and tests. Issues and pull requests welcome!
|
2018-06-30 06:37:24 -04:00
|
|
|
|
|
|
|
## Features
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
- Minification is done in one pass with no backtracking or DOM/AST building.
|
|
|
|
- No dynamic memory is allocated during processing, which increases safety and performance.
|
|
|
|
- Advanced whitespace handling options allow maximum minification while retaining valid spaces.
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
## Usage
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
This is the library. To use hyperbuild, you'll probably need one of these:
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
- [hyperbuild CLI](https://github.com/wilsonzlin/hyperbuild-cli)
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
Documentation for the library itself is currently WIP.
|
2018-08-04 07:41:44 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
hyperbuild uses the following dependencies, which are included as submodules:
|
2018-08-04 07:41:44 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
- [nicehash](https://github.com/wilsonzlin/nicehash)
|
2018-08-07 22:31:28 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
## Minification
|
2018-07-02 05:21:00 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
Guide below is currently WIP.
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
### Whitespace
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
hyperbuild has advanced whitespace minification that can allow strategies such as:
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
- leave whitespace untouched in `pre` and `code`, which are whitespace sensitive
|
|
|
|
- trim and collapse whitespace in content tags, as whitespace is collapsed anyway when rendered
|
|
|
|
- remove whitespace in layout tags, which allows the use of inline layouts while keeping formatted code
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Beginning and end
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2018-08-03 08:47:59 -04:00
|
|
|
```html
|
|
|
|
<p>↵
|
|
|
|
··The·quick·brown·fox↵
|
|
|
|
</p>
|
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Between text and tags
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2018-08-03 08:47:59 -04:00
|
|
|
```html
|
|
|
|
<p>The·quick·brown·fox·<strong>jumps</strong>·over·the·lazy·dog.</p>
|
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Contiguous
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2018-08-03 08:47:59 -04:00
|
|
|
```html
|
2018-08-03 08:54:37 -04:00
|
|
|
<select>↵
|
|
|
|
··<option>Jan:·········1</option>↵
|
|
|
|
··<option>Feb:········10</option>↵
|
|
|
|
··<option>Mar:·······100</option>↵
|
|
|
|
··<option>Apr:······1000</option>↵
|
|
|
|
··<option>May:·····10000</option>↵
|
|
|
|
··<option>Jun:····100000</option>↵
|
|
|
|
</select>
|
2018-08-03 08:47:59 -04:00
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Whole text
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2018-08-03 08:47:59 -04:00
|
|
|
```html
|
|
|
|
<p>↵
|
|
|
|
···↵
|
|
|
|
</p>
|
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
### Tag classification
|
|
|
|
|
|
|
|
|Type|Content|
|
|
|
|
|---|---|
|
|
|
|
|Formatting tags|Text nodes|
|
|
|
|
|Content tags|Formatting tags, text nodes|
|
|
|
|
|Layout tags|Layout tags, content tags|
|
|
|
|
|Content-first tags|Content of content tags or layout tags (but not both)|
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Specific tags
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2018-07-05 07:59:01 -04:00
|
|
|
Tags not in one of the categories below are **specific tags**.
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Formatting tags
|
2018-07-04 07:23:17 -04:00
|
|
|
|
|
|
|
```html
|
|
|
|
<strong> moat </strong>
|
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Content tags
|
2018-07-04 07:23:17 -04:00
|
|
|
|
|
|
|
```html
|
|
|
|
<p>Some <strong>content</strong></p>
|
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Content-first tags
|
2018-07-04 07:23:17 -04:00
|
|
|
|
|
|
|
```html
|
|
|
|
<li>Anthony</li>
|
|
|
|
```
|
|
|
|
|
|
|
|
```html
|
|
|
|
<li>
|
|
|
|
<div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
```
|
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
#### Layout tags
|
2018-07-04 07:23:17 -04:00
|
|
|
|
2018-08-03 08:47:59 -04:00
|
|
|
```html
|
|
|
|
<div>
|
|
|
|
<div></div>
|
|
|
|
</div>
|
|
|
|
```
|
2019-04-29 10:09:51 -04:00
|
|
|
|
|
|
|
## Development
|
2018-08-03 08:47:59 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
Currently, hyperbuild has a few limitations:
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
- Only UTF-8 is supported.
|
|
|
|
- Not aware of exotic Unicode whitespace characters.
|
|
|
|
- Follows HTML5 only.
|
|
|
|
- Only works on Linux.
|
2018-06-30 06:37:24 -04:00
|
|
|
|
2019-04-29 10:09:51 -04:00
|
|
|
Patches to change any of these welcome!
|