How to check if the browser supports picture-in-picture mode using JavaScript?

March 1, 2021 - 1 min read

To check if a browser supports picture-in-picture mode, you can use the pictureInPictureEnabled property in the global document object in JavaScript.

Picture-in-picture mode is a modern feature in browsers where the user will be able to play a video in an inset window (or a small separate window) even if the user is working on some other programs.

This is how you can check for the availability,

// Check if browser supports picture-in-picture mode
const doesitSupport = document.pictureInPictureEnabled;

console.log(doesitSupport); // true
  • The property returns a boolean true if it supports picture-in-picture mode and false if not

  • The pictureInPictureEnabled is still in a progress state at the time of the writing of this blog. Be sure to check the pictureInPictureEnabled compatibility table in caniuse.com.

See the above code live in JSBin.

Feel free to share if you found this useful 😃.