Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Save 3740 bytes gizpped by getting rid of xhr deps #6164

Merged
merged 5 commits into from
Aug 30, 2019

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Aug 7, 2019

es-abstract is huge, and there isn't really a reason for us to include it. See the changes here:
EDIT: made an actual pull request. videojs/xhr#1

└─┬ xhr@2.5.0
└─┬ parse-headers@2.0.2
└─┬ string.prototype.trim@1.2.0
└── es-abstract@1.13.0 deduped

We also are not using external helpers correctly, this pr fixes that as well.

subClass.super_ = superClass;
}
};
import _inherits from '@babel/runtime/helpers/inherits';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_inherits from babel is exactly the same as our code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since what we have is working, why change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since babel includes the _inherits from @babel/runtime/helpers/inherits in our code regardless, we may as well not include it twice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change broke a plugin #6328.

@gkatsev
Copy link
Member

gkatsev commented Aug 7, 2019

I guess trim is used for IE8 support. I wonder if they have a timeline for xhr@3, which should drop obsolete browser support. Made some comments on your xhr commit.
We'd want it published on npm before we merge it in.

Also, we should make sure that regenerator and its runtime aren't included as part of the runtime and external helpers stuff.

subClass.super_ = superClass;
}
};
import _inherits from '@babel/runtime/helpers/inherits';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since what we have is working, why change it?

'aes-decrypter',
'keycode'
]),
module(id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there documentation on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://rollupjs.org/guide/en/#external (ie it can be a function or a list)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was specifically looking for module rather than external.

package.json Outdated
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/node": "^7.4.5",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/plugin-external-helpers": "^7.2.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I played with it, using the external helpers actually made the file size much bigger, so, we should be careful with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do some file size tests without it, and just the xhr change.

'keycode'
]),
module(id) {
const result = moduleExternals.some((ext) => id.indexOf(ext) !== -1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would id.startsWith(ext) make sense here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi I changed this because @babel/runtime includes any number of helpers and we don't want to have to list them all :)

@brandonocasey
Copy link
Contributor Author

brandonocasey commented Aug 7, 2019


File w/o helpers with helpers master
video.min.js 140241 140241 144533
video.novtt.min.js 133869 133877 138317
video.core.min.js 57709 57736 61914
video.core.novtt.min.js 51329 51356 55786

It seems like with helpers is fine especially when we take into account that @videojs/http-streaming, mpd-parser, m3u8-parser, pkc7s, mux.js, and aes-decryptr all include there own helpers right now because the es module that they export does not use @babel/runtime since they don't use external/runtime helpers. Once we have them doing that with helpers should be much smaller.

@gkatsev
Copy link
Member

gkatsev commented Aug 7, 2019

Cool, those differences are much smaller than last time I tried them out, and we still end up with a smaller output. Yeah, updating those to have better es builds would give us even more savings.

@gkatsev gkatsev added the minor This PR can be added to a minor release. It should not be added to a patch release. label Aug 21, 2019
@brandonocasey
Copy link
Contributor Author

Final size versus master (which just saw a size decrease from a video.js change): 131924 to 128184 for video.min.js or 3740 gzipped bytes and it should be about the same for every dist file.

@brandonocasey brandonocasey changed the title perf: Save 4372 bytes gizpped by getting rid of xhr deps perf: Save 3740 bytes gizpped by getting rid of xhr deps Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor This PR can be added to a minor release. It should not be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants