-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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: Another 5ms of startup time improvements #6145
Conversation
@@ -57,7 +56,7 @@ class ErrorDisplay extends ModalDialog { | |||
* | |||
* @private | |||
*/ | |||
ErrorDisplay.prototype.options_ = mergeOptions(ModalDialog.prototype.options_, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.assign is much faster.
@@ -55,7 +53,7 @@ const REMOTE = { | |||
} | |||
}; | |||
|
|||
const ALL = mergeOptions(NORMAL, REMOTE); | |||
const ALL = Object.assign({}, NORMAL, REMOTE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.assign is much faster.
@@ -160,7 +160,7 @@ export function createEl(tagName = 'div', properties = {}, attributes = {}, cont | |||
// method for it. | |||
} else if (propName === 'textContent') { | |||
textContent(el, val); | |||
} else { | |||
} else if (el[propName] !== val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is also another big startup time user. We should make sure that the prop is not already equal to what we are going to set it to before doing it.
@@ -84,6 +84,9 @@ function _handleMultipleEvents(fn, elem, types, callback) { | |||
* Fixed event object. | |||
*/ | |||
export function fixEvent(event) { | |||
if (event.fixed_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This costs us 0.1 ms per event, but some event have it done to them 5+ times. Might as well only do it once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always go into the line 101/104 block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we almost always do yeah.
}); | ||
let _supportsPassive; | ||
|
||
const supportsPassive = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason this takes about 2ms to complete, making it lazy makes it take much less time later when an event that would need to be passive is actual used.
src/js/tech/html5.js
Outdated
['featuresNativeTextTracks', 'supportsNativeTextTracks'], | ||
['featuresNativeVideoTracks', 'supportsNativeVideoTracks'], | ||
['featuresNativeAudioTracks', 'supportsNativeAudioTracks'] | ||
].forEach(function(array) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
altogether these take about 1ms at startup.
59e1f65
to
e730ecd
Compare
@@ -84,6 +84,9 @@ function _handleMultipleEvents(fn, elem, types, callback) { | |||
* Fixed event object. | |||
*/ | |||
export function fixEvent(event) { | |||
if (event.fixed_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always go into the line 101/104 block?
@@ -566,5 +567,7 @@ videojs.dom = Dom; | |||
*/ | |||
videojs.url = Url; | |||
|
|||
videojs.defineLazyProperty = defineLazyProperty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to expose it currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will need it in a few other places, vhs for sure.
85c7369
to
4fcb0af
Compare
Skipping the tabIndex property on created elements due to videojs#6145 optimizations blocks them from receiving keyboard events, due to not being focusable; for example this breaks closing ModalDialog elements by pressing Escape. Fix this by always setting tabIndex, as the element may return the same value even though the property has not been explicitly set. Fixes videojs#6870
Skipping the tabIndex property on created elements due to #6145 optimizations blocks them from receiving keyboard events, due to not being focusable; for example this breaks closing ModalDialog elements by pressing Escape. Fix this by always setting tabIndex, as the element may return the same value even though the property has not been explicitly set. Fixes #6870
Skipping the tabIndex property on created elements due to videojs#6145 optimizations blocks them from receiving keyboard events, due to not being focusable; for example this breaks closing ModalDialog elements by pressing Escape. Fix this by always setting tabIndex, as the element may return the same value even though the property has not been explicitly set. Fixes videojs#6870
See code comments