From 996ba336e22162597d8fcbcb6c588f897f861f49 Mon Sep 17 00:00:00 2001 From: Timothy Farrell Date: Fri, 23 Dec 2016 08:14:31 -0600 Subject: [PATCH] README cleanup --- packages/trimkit/README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/trimkit/README.md b/packages/trimkit/README.md index a725277..cb2d413 100644 --- a/packages/trimkit/README.md +++ b/packages/trimkit/README.md @@ -3,29 +3,37 @@ TrimKit is a set of DOM and API abstractions for the purpose of better Javascript minification. For example: - if (a === undefined) { alert('Oops'); } +``` +if (a === undefined) { alert('Oops'); } +``` minifies down to: - if(a===void 0){alert('Oops')} +``` +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; } +``` +function isUndefined(a) { return a === void 0; } - if (isUndefined(a)) { alert('Oops'); } +if (isUndefined(a)) { alert('Oops'); } +``` which minifies down to: - function b(a){return a===void 0} +``` +function b(a){return a===void 0} - if (b(a)){alert('Oops');} +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 after compression losses. YMMV. +pre-compression gains can result in post-compression losses. YMMV. # Abstractions