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:- ES Modules
- UMD (Browser)
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
- JavaScript
- Data Attribute
Vimeo Videos
Vimeo videos work the same way as YouTube:- JavaScript
- Data Attribute
Self-Hosted Videos
For self-hosted videos, specify video formats prefixed with the format type:- JavaScript
- Data Attribute
You only need one video format, not all three. Providing multiple formats ensures maximum browser compatibility. Common formats:
mp4, webm, ogvSingle Format Example
Video Configuration Options
videoStartTime
videoStartTime
Start the video at a specific time in seconds.Default:
0videoEndTime
videoEndTime
End the video at a specific time in seconds.Default:
0 (plays until the end)videoLoop
videoLoop
Loop the video infinitely.Default:
truevideoVolume
videoVolume
Set video volume from 0 to 100.Default:
0 (muted)videoPlayOnlyVisible
videoPlayOnlyVisible
Play video only when it’s visible in the viewport.Default:
truevideoLazyLoading
videoLazyLoading
Load video only when it becomes visible in the viewport.Default:
truevideoClass
videoClass
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-localDisable Videos on Mobile
You can disable video loading on mobile devices to improve performance: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:- With jarallax-img
- With imgSrc option
Video Events
The video extension provides additional events for video lifecycle management:onVideoInsert
onVideoInsert
Called when the video element is inserted into the DOM.Access the video element via
this.$videoonVideoWorkerInit
onVideoWorkerInit
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:Next Steps
Advanced Options
Explore different parallax types and performance optimization
Events & Methods
Learn about the API for controlling parallax instances
