Skip to main content

Quick Start Guide

This guide will walk you through creating your first parallax effect with Jarallax. You’ll go from zero to a working parallax scrolling background in just a few steps.

Basic Parallax Image

The simplest way to use Jarallax is with a background image and the <img> tag.
1

Add the HTML structure

Create a container element with the jarallax class and an <img> element with the jarallax-img class:
Add a minimum height to your parallax container so it has dimensions to work with.
2

Initialize Jarallax

Call the jarallax function on your elements:
Or with custom options:
3

See it in action

Scroll the page and watch your background move at a different speed than your content!

Alternative: CSS Background Image

You can also use CSS background images instead of <img> tags:

Data Attribute Initialization

When using UMD mode, Jarallax can automatically initialize elements with the data-jarallax attribute:
With data attributes, you can configure all options directly in HTML. For example: data-speed="0.5", data-type="scale", data-img-position="0% 50%".

Complete Working Example

Here’s a full HTML page with a working parallax effect:

Video Background Example

Add a YouTube or Vimeo video as a parallax background:
1

Load the video extension

2

Add HTML with video URL

3

Initialize with videoSrc option

Supported Video Formats

For self-hosted videos, provide at least one format (mp4, webm, or ogv). Multiple formats ensure better browser compatibility.

Customizing Speed

The speed option controls how fast the background moves relative to scrolling:
Speed values range from -1.0 to 2.0:
  • < 0: Background moves in reverse
  • 0.0 - 0.9: Background moves slower (parallax effect)
  • 1.0: No parallax (fixed background)
  • > 1.0: Background moves faster

Different Effect Types

Jarallax supports multiple effect types:

Using with Picture Element

For responsive images with different sources:

Disable on Mobile

Optionally disable parallax on mobile devices for better performance:
Or use a function:

Common Patterns

Hero Section

Multiple Sections

Troubleshooting

  • Ensure the container has a defined height
  • Check that CSS file is loaded
  • Verify jarallax function is called after DOM is ready
  • Check browser console for errors
  • Verify image path is correct
  • Check that image has loaded (Network tab)
  • Ensure CSS is properly loaded
  • Try using imgSrc option directly: jarallax(element, { imgSrc: 'path/to/image.jpg' })
  • Use the disableParallax option to disable on mobile
  • Reduce image file sizes
  • Consider using disableVideo for video backgrounds on mobile

Next Steps

Now that you have a working parallax effect, explore more advanced features:

Configuration Options

Learn about all available options and callbacks

API Reference

Explore methods and programmatic control

Video Backgrounds

Deep dive into video parallax features

Examples

Browse more example implementations