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

refactor redundant code in html5 tech #3593

Merged
merged 5 commits into from
Sep 29, 2016
Merged

refactor redundant code in html5 tech #3593

merged 5 commits into from
Sep 29, 2016

Conversation

brandonocasey
Copy link
Contributor

Description

  • Refactor any redundant code in the html5 tech to save bytes
  • saved 254 bytes in the gzipped bundle, or 0.4% savings

Specific Changes proposed

  • List native properties wrappers at the top and loop through and add them in the constructor
  • Better video/audio track code

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

@misteroneill
Copy link
Member

Personally, I think this is better and the byte savings are a nice added bonus. 👍 Will review in more detail later.

@gkatsev
Copy link
Member

gkatsev commented Aug 31, 2016

We probably should add these functions to the prototype programmatically, not in the constructor.

@misteroneill
Copy link
Member

Yeah, that sounds like a good idea.

@dmlap
Copy link
Member

dmlap commented Sep 1, 2016

Will we lose documentation for these functions?

@brandonocasey
Copy link
Contributor Author

we will lose documentation for these methods

@brandonocasey
Copy link
Contributor Author

maybe we can keep the comments without keeping the code?

@misteroneill
Copy link
Member

There may be a way of documenting them that I'm not aware of (I've tried a few things in the past), but one thing you can definitely do is something like this:

/**
 * Begins playback.
 * 
 * @method play
 * @memberof Player
 */
Player.prototype.play;

Not sure that's exactly it, but it's close. I'm not sure if that'd get dropped by uglify or not.

@misteroneill
Copy link
Member

Another alternative would be to do keep the methods as noops by default:

/**
 * Begins playback.
 */
play() {}

Of course, that probably negates the byte savings.

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: e00add00aa8192c7e2e517f832d5cba9a9820e59
Build details: https://travis-ci.org/pam/video.js/builds/157173180

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: b38b45e
Build details: https://travis-ci.org/pam/video.js/builds/157174054

(Please note that this is a fully automated comment.)

slight documentation updates to follow jsdoc conventions
@brandonocasey
Copy link
Contributor Author

@dmlap @misteroneill added the doc-comments back in for these methods without extra code

@pam
Copy link

pam commented Sep 2, 2016

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 3ec4ccb
Build details: https://travis-ci.org/pam/video.js/builds/157190308

(Please note that this is a fully automated comment.)

*
* @method Html5.prototype.paused
* @return {Boolean}
*/
Copy link
Member

Choose a reason for hiding this comment

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

Nice. Glad to see this works! 👍

@misteroneill
Copy link
Member

LGTM

@misteroneill misteroneill added patch This PR can be added to a patch release. confirmed labels Sep 7, 2016
@brandonocasey brandonocasey added needs: LGTM Needs one or more additional approvals and removed confirmed labels Sep 12, 2016
@misteroneill
Copy link
Member

LGTM

@misteroneill misteroneill added confirmed and removed needs: LGTM Needs one or more additional approvals labels Sep 12, 2016
fix removeTrack typo
Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

Made a couple relatively minor comments.

/**
* Play for html5 tech
*
* @method play
Copy link
Member

Choose a reason for hiding this comment

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

does jsdoc figure out this @method itself?

Copy link
Member

Choose a reason for hiding this comment

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

I believe that is the case.

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 it does

*/
'playbackRate'
].forEach(function(prop) {
Html5.prototype[`set${toTitleCase(prop)}`] = function(v) {
Copy link
Member

@gkatsev gkatsev Sep 20, 2016

Choose a reason for hiding this comment

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

might be more readable to just do 'set' + toTitleCase(prop).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

LGTM.
Test is broken due to the firefox issue.

@gkatsev gkatsev added this to the 5.12 milestone Sep 27, 2016
@gkatsev gkatsev merged commit 6878c21 into videojs:master Sep 29, 2016
@brandonocasey brandonocasey deleted the chore/refactor-html5-tech branch September 29, 2016 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed patch This PR can be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants