explaingit

markdalgleish/stellar.js

4,595JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A jQuery plugin for parallax scrolling effects that makes background images and page elements move at different speeds as you scroll, creating a depth illusion with minimal code. No longer actively maintained.

Mindmap

mindmap
  root((Stellar.js))
    What it does
      Parallax scrolling
      Depth effects
      Speed ratios
    Configuration
      Scroll ratio
      Element offsets
      Scroll plugins
    Use cases
      Landing pages
      Layered backgrounds
      Custom scroll UI
    Audience
      Front-end developers
      Designers with code
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add depth to a landing page hero section by making background images scroll at a fraction of the normal speed.

USE CASE 2

Layer multiple page elements at different scroll speeds to create a multi-plane depth effect without CSS animation code.

USE CASE 3

Adapt Stellar.js to a custom scrolling container using its plugin API for non-standard scroll position sources.

Tech stack

JavaScriptjQuery

Getting it running

Difficulty · easy Time to first run · 5min

Note: the project is no longer actively maintained, no new features or bug fixes are planned.

In plain English

Stellar.js is a jQuery plugin that makes parallax scrolling effects easy to add to any webpage. Parallax scrolling is a visual technique where background images or page elements move at a different speed than the rest of the page as you scroll, creating a sense of depth. The project is no longer actively maintained, but its code remains available and a path exists for contributors to take over. To use it, you run a single function call against any scrollable element on the page, such as the browser window or a specific container. Stellar.js then scans that element for anything tagged with special HTML data attributes and adjusts those items' positions as the user scrolls. You can apply it to both background images and to regular page elements like divs or images. The core idea is a "ratio" value you set on each element. A ratio of 0.5 means the element scrolls at half the normal speed, while a ratio of 2 means it moves at twice the speed. This lets you layer elements at different apparent depths with minimal code. You can also set offsets, which control where each element snaps back to when its containing section reaches the edge of the viewport, allowing more complex layered compositions. For advanced setups, Stellar.js supports custom scroll property plugins. If your scrolling interface works through CSS transforms, margins, or another mechanism rather than the standard browser scroll position, you can write a small adapter so the library knows how to read your scroll state. Positioning can also be handled via CSS transforms rather than standard top and left values, which is necessary for smooth scrolling on older iOS devices. The library exposes a straightforward configuration object covering scroll direction, offset defaults, whether to hide off-screen parallax elements, and how elements are shown or hidden. The README is direct about the project's status: no new features are planned, and anyone who wants it maintained should apply to become a contributor.

Copy-paste prompts

Prompt 1
Using Stellar.js, set up a parallax hero section where the background image scrolls at 0.3 speed and a foreground element scrolls at 0.7 speed. Show the HTML data attributes and the jQuery init call.
Prompt 2
How do I apply Stellar.js parallax to a scrollable div container instead of the browser window? Show the configuration options.
Prompt 3
I want to use Stellar.js with CSS transforms for smooth scrolling on mobile iOS. What options do I set and how does the data attribute change?
Prompt 4
My Stellar.js elements disappear when they scroll off screen. How do I keep them visible using the hideDistantElements setting?
Open on GitHub → Explain another repo

← markdalgleish on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.