Categories: CSSScriptWeb Design

Customizable Fullscreen Loading Screen with JavaScript – SWL.js

SenangWebs Loading (SWL) is a lightweight JavaScript library that displays a customizable, fullscreen loading indicator while assets like images, scripts, and dynamic content are loading on your webpage.

It can be used to enhance the browsing experience by providing visual feedback during the loading process. This reduces perceived wait times and keeps users engaged.

The library supports various loader types, including spinners, pulsing animations, and custom images. You can customize the appearance to fit your site’s design through color customization and backdrop blur effects.

How to use it:

1. Download the swl.js JavaScript library and include it on your webpage.

<script src="/dist/swl.js"></script>

2. The SWL library uses data attributes to customize the loader’s appearance and behavior. Here’s how you can configure it:

  • data-swl-pulse: Use pulsing loader
  • data-swl-image: Use custom image
  • data-swl-color: Set loader color
  • data-swl-duration: Set minimum display time (ms)
  • data-swl-bg-color: Set overlay background color
  • data-swl-bg-opacity: Set overlay opacity (0-1)
  • data-swl-bg-blur: Set background blur (px)
  • data-swl-z-index: Set overlay z-index
<body 
  data-swl-color="#007bff" 
  data-swl-duration="2000"
  data-swl-bg-color="#ffffff" 
  data-swl-bg-opacity="0.8"
  data-swl-bg-blur="5"
  data-swl-z-index="9999"
>

How it works:

When the swl.js script loads, it creates a loading overlay (swl-overlay), a backdrop (swl-backdrop), and a content container (swl-content). The chosen loading animation (spinner, pulse, or custom image) is added to this content container.

The script then applies styles based on the data attributes provided in the body tag. These styles control the appearance of the loading screen, such as color, blur, and opacity.

A small piece of JavaScript then calculates the remaining display time for the loader based on the data-swl-duration setting and the initial page load time. After the page fully loads, the loading screen is hidden.

Changelog:

v1.1.8 (05/02/2025)

  • Refactor

v1.1.5 (10/27/2024)

  • Update color scheme & remove redundances

The post Customizable Fullscreen Loading Screen with JavaScript – SWL.js appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Agreement With Toll Road Operator

FORT WAYNE, Ind. (WOWO) — The state of Indiana has agreed to let the Indiana…

53 minutes ago

Multiple Storm Rounds

FORT WAYNE, Ind. (WOWO) — Severe thunderstorms are expected to move across central Indiana in…

53 minutes ago

Universal Pictures at CinemaCon 2026: Everything Revealed

Universal Pictures and Focus Features have taken the stage at CinemaCon. We're expecting new looks…

54 minutes ago

Tax Day 2026: Democrats and Republicans battle over impact of new Trump tax cuts

Maritza Montejo, a Liberty Tax Service office manager, helps Aurora Hernandez, left, with her taxes…

58 minutes ago

Union Accuses Rockford Schools of Ignoring Bilingual Class Size Law

The Rockford Education Association is accusing Rockford Public Schools 205 of unfair labor practices. The…

1 hour ago

Severe storms cause extensive damage in Pearl City, Illinois

Severe storms from Tuesday, April 14, caused significant damage in Pearl City, Stephenson County, including…

1 hour ago

This website uses cookies.