Timothy Farrell 3328248274 Apply standard/enforced code format with prettier.
This commit marks applying prettier to the whole of git history up to this point and prettier is used to enforce format via pre-commit hook. The command used was: `git filter-branch -f --tree-filter 'prettier --no-config --single-quote --tab-width=1 --print-width=100 --use-tabs --trailing-comma=none --prose-wrap=always --write "{.,{packages,bin}/**}/*.{js,json,md}" || echo "Error formatting, possibly invalid JS"' -- --all`
2018-07-19 07:52:42 -05:00

53 lines
1.1 KiB
Markdown

# [TrimKit](https://gitlab.com/explorigin/trimkit)
TrimKit is a set of DOM and API abstractions for the purpose of better Javascript minification. For
example:
```
if (a === undefined) { alert('Oops'); }
```
minifies down to:
```
if(a===void 0){alert('Oops')}
```
If we compare against undefined more than 3 times, we can save bytes by doing this:
```
function isUndefined(a) { return a === void 0; }
if (isUndefined(a)) { alert('Oops'); }
```
which minifies down to:
```
function b(a){return a===void 0}
if (b(a)){alert('Oops');}
```
With enough uses of common APIs, you can win back some bytes.
NOTE: TrimKit will help you obsess about Javascript file sizes but that does not always translate to
smaller files after you apply compression. Because files using have more entropy, small,
pre-compression gains can result in post-compression losses. YMMV.
# Abstractions
- `undefined`
- `requestAnimationFrame`
- `Array.isArray`
- `Array.from`
- `Object.keys`
- `document`
- `typeof obj === 'function'`
- `typeof obj === 'string'`
- `typeof obj === 'number'`
- `null`
- `obj === undefined`
- `obj === null`
- `fn.apply(context, params)`