Some optimizations by hand, add TypeScript declaration#35
Open
jhpratt wants to merge 1 commit intotypicode:masterfrom
jhpratt:master
Open
Some optimizations by hand, add TypeScript declaration#35jhpratt wants to merge 1 commit intotypicode:masterfrom jhpratt:master
jhpratt wants to merge 1 commit intotypicode:masterfrom
jhpratt:master
Conversation
Also update dependencies (for security reasons) and replace uglify-js with terser. I intentionally did not modernize any code, so as to preserve browser compatibility. --- Optimizations explanation: Line 1: See line 95. Line 17: If `json` is not present, it's the fallback anyways. We can safely remove this value from the checks. Though replacing the `indexOf` check with multiple checks seems like it would increase size, gzip easily turns this into a net savings. Line 95: If window is defined, we'd be using the window variable anyways. If it wasn't defined (AKA held the value `undefined`), we would use `undefined`. This can be simplified into just using `window`. Because we're simply passing the verbatim into the IIFE, we can eliminate this entirely.
Author
|
Looks like the test is failing due to the environment that Travis is configured for, not because of an issue with the library. |
Author
|
Just in case anyone runs across this, I've just published |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basically, I added a TS declaration and reduced the minzip size from 629B to 582B (-7.5%) and the min-brotli size from 524B to 487B (-7.1%). I intentionally did not modernize any code, so as to preserve browser compatibility.
I also updated dependencies (for security reasons) and replace uglify-js with terser.
Optimizations explanation:
Line 1: See line 95.
Line 17: If
jsonis not present, it's the fallback anyways. We cansafely remove this value from the checks. Though replacing the
indexOfcheck with multiple checks seems like it would increase size, gzip
easily turns this into a net savings.
Line 95: If window is defined, we'd be using the window variable
anyways. If it wasn't defined (AKA held the value
undefined), we woulduse
undefined. This can be simplified into just usingwindow.Because we're simply passing the verbatim into the IIFE, we can
eliminate this entirely.
Resolves #29.