Skip to main content
Jarallax supports video backgrounds with parallax effects through the video extension. This guide covers how to implement video parallax with different video sources.

Installation

The video extension requires both the core Jarallax library and the video extension:

Setup

Import and initialize the video extension before using video parallax:
The video extension uses the video-worker library internally to handle YouTube, Vimeo, and self-hosted videos.

YouTube Videos

YouTube videos are the most common video source for parallax backgrounds.
1

Create HTML Structure

2

Initialize with videoSrc

YouTube short URLs also work: https://youtu.be/ab0TSkLe-E0

Vimeo Videos

Vimeo videos work the same way as YouTube:

Self-Hosted Videos

For self-hosted videos, specify video formats prefixed with the format type:
You only need one video format, not all three. Providing multiple formats ensures maximum browser compatibility. Common formats: mp4, webm, ogv

Single Format Example

Video Configuration Options

Start the video at a specific time in seconds.
Default: 0
End the video at a specific time in seconds.
Default: 0 (plays until the end)
Loop the video infinitely.
Default: true
Set video volume from 0 to 100.
Default: 0 (muted)
Many browsers block autoplaying videos with sound. Keep videos muted for best compatibility.
Play video only when it’s visible in the viewport.
Default: true
This option improves performance by pausing videos that are not visible.
Load video only when it becomes visible in the viewport.
Default: true
Lazy loading significantly improves initial page load performance when you have multiple video backgrounds.
CSS class added to the video element.
Default: 'jarallax-video'The video type is automatically appended: jarallax-video-youtube, jarallax-video-vimeo, or jarallax-video-local

Disable Videos on Mobile

You can disable video loading on mobile devices to improve performance:
Or using a function:
When disableVideo is active, Jarallax will display a fallback image instead (either from imgSrc option or the video thumbnail).

Adding Fallback Images

Provide a fallback image for when the video is loading or disabled:
For self-hosted videos, the fallback image is automatically set as the video poster attribute.

Video Events

The video extension provides additional events for video lifecycle management:
Called when the video element is inserted into the DOM.
Access the video element via this.$video
Called when the VideoWorker instance is initialized.
The VideoWorker instance is passed as a parameter.

Complete Video Example

Here’s a complete example with YouTube video:

Advanced: Multiple Videos

You can have multiple video backgrounds on the same page:
With videoLazyLoading and videoPlayOnlyVisible enabled, only visible videos will load and play, optimizing performance.

Next Steps

Advanced Options

Explore different parallax types and performance optimization

Events & Methods

Learn about the API for controlling parallax instances