npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

railroad-loader

v1.2.0

Published

Animated DNA helix loader with terminal-style progress messages. Built on Railroad Runtime philosophy.

Downloads

38

Readme

Railroad Loader

Animated DNA helix loader with terminal-style progress messages.

Part of the Railroad ecosystem — Pure DOM utilities that work standalone or with Railroad Runtime.

Zero dependencies. ~2KB minified.


Features

✅ Animated DNA helix spinner
✅ Cycling progress messages
✅ Minimum display duration (prevents flash)
✅ HTMX integration (automatic)
✅ Simple API (show() / hide())
✅ Customizable messages


Installation

** CDN (fastest):**

<script src="https://unpkg.com/[email protected]/dist/loader.min.js"></script>

npm:

npm install railroad-loader

Quick Start

Basic Usage

// Show loader
RailroadLoader.show();

// Hide loader (respects min duration)
RailroadLoader.hide();

With Custom Messages

RailroadLoader.show([
  'Loading posts...',
  'Fetching comments...',
  'Rendering view...',
  'Almost done...'
]);

// Hide after async operation
fetchData().then(() => {
  RailroadLoader.hide();
});

With HTMX (Automatic)

<!-- Loader shows/hides automatically -->
<div hx-get="/api/data" hx-target="#content">
  Load Data
</div>

No JavaScript needed! Loader appears automatically on HTMX requests.


API

RailroadLoader.show(messages?)

Show the loader.

Parameters:

  • messages (Array, optional) - Custom messages to cycle through

Example:

RailroadLoader.show(['Processing...', 'Building...', 'Done!']);

RailroadLoader.hide()

Hide the loader. Respects minimum display duration (500ms) to prevent flash.

Example:

RailroadLoader.hide();

RailroadLoader.isLoading()

Check if loader is currently visible.

Returns: boolean

Example:

if (RailroadLoader.isLoading()) {
  console.log('Still loading...');
}

RailroadLoader.setMessages(messages)

Update the default messages.

Parameters:

  • messages (Array) - New default messages

Example:

RailroadLoader.setMessages([
  'Loading...',
  'This might take a moment...',
  'Still working...'
]);

HTMX Integration

Railroad Loader automatically integrates with HTMX if present:

<script src="https://unpkg.com/htmx.org"></script>
<script src="https://unpkg.com/railroad-loader"></script>

<!-- Loader shows automatically on request -->
<button hx-get="/api/data">Fetch Data</button>

Loader lifecycle:

  1. htmx:beforeRequest → Loader shows
  2. Request in progress → Messages cycle
  3. htmx:afterRequest → Loader hides (respects min duration)

Examples

Async Operations

async function saveSettings() {
  RailroadLoader.show(['Saving settings...', 'Validating...', 'Done!']);
  
  try {
    await fetch('/api/settings', {method: 'POST', body: data});
    RailroadLoader.hide();
    toast('Settings saved', 'success');
  } catch (err) {
    RailroadLoader.hide();
    toast('Save failed', 'error');
  }
}

Form Submission

document.querySelector('form').addEventListener('submit', async (e) => {
  e.preventDefault();
  
  RailroadLoader.show(['Submitting form...', 'Processing...']);
  
  await submitForm(e.target);
  
  RailroadLoader.hide();
});

Multiple Steps

async function deployApp() {
  RailroadLoader.show([
    'Building application...',
    'Running tests...',
    'Deploying to server...',
    'Verifying deployment...',
    'Complete!'
  ]);
  
  await build();
  await test();
  await deploy();
  await verify();
  
  RailroadLoader.hide();
}

Styling

The loader is centered on screen by default. Customize via CSS:

#railroad-loader {
  /* Change position */
  top: 30% !important;
  
  /* Change colors */
  color: #f0f0f0 !important;
}

#railroad-loader svg circle {
  /* Change helix colors */
  fill: #your-color !important;
}

Minimum Display Duration

The loader enforces a 500ms minimum display duration to prevent flash:

RailroadLoader.show();

// Even if data loads in 50ms, loader stays for 500ms
fetch('/fast-endpoint').then(() => {
  RailroadLoader.hide();  // Will hide after 500ms total
});

This prevents jarring flash when data loads quickly.


Works With

✅ Vanilla JavaScript (no dependencies)
✅ HTMX (automatic integration)
✅ Alpine.js
✅ Turbo/Hotwire
✅ Any framework or no framework


Why Railroad Loader?

Other loaders:

  • Complex configuration
  • Framework dependencies
  • No HTMX integration
  • Generic spinners

Railroad Loader:

  • Zero config (works out of the box)
  • Zero dependencies
  • Automatic HTMX integration
  • Unique DNA helix animation
  • Terminal-style messages

One line to get started:

<script src="https://unpkg.com/railroad-loader"></script>

License

MIT

Contributing

Issues and PRs welcome at https://github.com/faroncoder/railroad-loader


Part of the Railroad ecosystem:

Not a framework. Just utilities.