Getting Started

An overview of how to get started using Video.js, from basic CDN usage to Browserify, along with examples.

Download

There are a few ways to get started using Video.js (currently v8.10.0), but you should select the one that best fits your particular use case.

Video.js CDN

Our friends at Fastly are nice enough to provide hosting for all the necessary files for Video.js on their content delivery network. Using these hosted files is probably the easiest way to get started using Video.js, you simply need to include the following links in your page.

<head>
  <link href="https://vjs.zencdn.net/8.10.0/video-js.css" rel="stylesheet" />

  <!-- If you'd like to support IE8 (for Video.js versions prior to v7) -->
  <!-- <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script> -->
</head>

<body>
  <video
    id="my-video"
    class="video-js"
    controls
    preload="auto"
    width="640"
    height="264"
    poster="MY_VIDEO_POSTER.jpg"
    data-setup="{}"
  >
    <source src="MY_VIDEO.mp4" type="video/mp4" />
    <source src="MY_VIDEO.webm" type="video/webm" />
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a
      web browser that
      <a href="https://videojs.com/html5-video-support/" target="_blank"
        >supports HTML5 video</a
      >
    </p>
  </video>

  <script src="https://vjs.zencdn.net/8.10.0/video.min.js"></script>
</body>

Install via npm

For more advanced workflows, installing via npm is recommended

$ npm install --save-dev video.js

Internet Explorer Support

Beginning with v7, we will no longer support Microsoft Internet Explorer versions prior to IE 11, including IE 8, 9, and 10. Microsoft dropped support for these versions over two years ago, they are widely considered out of compliance with modern security standards, and they comprise less than 0.1% of Video.js browser usage.

For versions of Video.js prior to v7, there are a few common things you should keep in mind regardless of how you end up including Video.js in your project. The core codebase uses a few modern features of Javascript (ES5), so if you'd like to support IE8 you'll need to include an ES5 shim. To make things easier, we created a single file you can include for IE8 support. No matter where the core Video.js library is placed, this file needs to be located in the <head> of the document.

Google Analytics

We include a stripped down Google Analytics pixel that tracks a random percentage (currently 1%) of players loaded from the CDN. This allows us to see (roughly) what browsers are in use in the wild, along with other useful metrics such as OS and device. If you'd like to disable analytics, you can simply include the following global before including Video.js via the free CDN:

Note: v7 will not send any data, and v6.8 and up respect the browser's do not track flag.

window.HELP_IMPROVE_VIDEOJS = false;

What's in the box?

If you've downloaded one of the releases or installed via a package manager, you've probably noticed that the contents are slightly different from the source code available on Github. The former includes just the compiled files necessary to use Video.js, and the latter includes the source used to create those files.

Distributions

A Video.js distribution is what you'll find if you've downloaded a release or installed via a package manager.

Video.js/
├── alt
│   ├── video.core.js
│   ├── video.core.min.js
│   ├── video.core.novtt.js
│   ├── video.core.novtt.min.js
│   ├── video.novtt.js
│   └── video.novtt.min.js
├── examples/
├── font
│   ├── VideoJS.svg
│   ├── VideoJS.ttf
│   └── VideoJS.woff
├── lang/
├── video-js-<span class="vjs-version">$LATEST_VERSION$</span>.zip
├── video-js.css
├── video-js.min.css
├── video.cjs.js
├── Video.es.js
├── Video.js
└── video.min.js

This package includes everything you'll need to use Video.js on a production site. By default, we bundle Video.js with Mozilla's excellent VTT.js. If you don't need VTT.js functionality for whatever reason, you can use one of the Video.js copies that don't include VTT.js. These have novtt in the name and can be found in the alt/ directory. font/ includes all the generated icon font files from the Videojs Font project. lang/ contains all the generated translation files.

Source Code

The source code is everything you'll find when checking out the Video.js git repository. This includes all the source files and any tooling necessary to build a production ready version of Video.js, as well as useful development tools such as sandboxed examples.

A lot of the root source directory is JSON configs for various package managers because, Internet. Most likely the important things you're looking for will be in src/ and build/. src/ contains all of the source files for both the player JS and the base skin, while the build/ directory contains various grunt tasks as well as the primary build file, grunt.js.

Build Tools

Before getting started, you'll need Node.js installed. See CONTRIBUTING.md for more details.

Customize

Using Video.js straight out of the box is fine, but we think it's better if you make it your own. Plugins and skins make it possible to completely customize your player.

Skinning

The player skin is completely built from HTML and CSS, including when other players like YouTube are used.

Skin changes can be as simple as centering the play button (you can just add the 'vjs-big-play-centered' class to your video tag), or as complex as creating entirely new layouts. We've built a codepen project where you can explore different changes.

Home Page Themes

The themes in the home page come from the Videojs Themes library. To use them in your player, import the CSS, then add the relevant class to your video tag. For example, if you want to use the City theme, you could set up your HTML like so:

<!-- In the head of your document with your other CSS includes... -->
<!-- Video.js base CSS -->
<link
  href="https://unpkg.com/video.js@7/dist/video-js.min.css"
  rel="stylesheet"
/>

<!-- City -->
<link
  href="https://unpkg.com/@videojs/themes@1/dist/city/index.css"
  rel="stylesheet"
/>

<!-- Then, in the player -->
<video class="video-js vjs-theme-city" ...></video>

Designing your own

A great place to start is the Video.js Skin Designer, but at the end of the day we suggest using the cascading aspect of CSS to simply override the parts of the design you want to customize.

Plugins

Video.js by itself is purposefully very simple. It supports the basic video and audio playback features and ensures they work the same across different playback technologies ("techs"). Any more advanced features are built as plugins, including playlists, analytics, advertising, and support for advanced formats like HLS and DASH. Check out the plugins page to see what's available.

Video.js Plugins