DEV Community

Cover image for YouTube speed control with JavaScript
Walter Nascimento
Walter Nascimento

Posted on

17 2

YouTube speed control with JavaScript

[Clique aqui para ler em português]

On YouTube the biggest speed of the player is only 2x, but sometimes we fall into a video that even when you put it in 2x it still seems like the person is talking very slowly, and for these cases the ideal would be to increase the speed even more, so let’s create a script that solves this with JavaScript.

Step by step

  1. First access any YouTube video, Ex .:(https://www.youtube.com/watch?v=RC6qFlXxsio)
  2. Then open your browser console (F12)
  3. Go to the console tab and type:
document.getElementsByClassName("video-stream html5-main-video")[0].playbackRate = 2.5;
Enter fullscreen mode Exit fullscreen mode

After typing and enter your video will play 2.5x faster if you want even faster just change the 2.5 for the number you want and if you want to slow down just put a smaller number, example (0.5).

In the script I also added for vimeo, you have to follow the same step by step and at the end execute the script:

document.querySelector('video').playbackRate = 2.5;
Enter fullscreen mode Exit fullscreen mode

Follow the script on gist

// Youtube
document.getElementsByClassName("video-stream html5-main-video")[0].playbackRate = 2.5;
// Vimeo
document.querySelector('video').playbackRate = 2.5;

Thanks for reading!

If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!

😊😊 See you! 😊😊

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (1)

Collapse
 
circuit10 profile image
circuit10

Doing it this way causes the subtitles to desync

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more