Blur loading in HTML 5 with source code

Blur loading in HTML 5 with source code


Blur loading is a web-based project. It is coded in HTML5, CSS, and JavaScript. This tutorial deals with creating a blur loading image with the counter.

In this tutorial, we will be creating a blur loading page. First, we need to create a folder with images folder and files. We will be using images and numbers. We will create a simple webpage that shows the blurry loading effect. We will use CSS and JavaScript for making blur loading.

It is a static webpage that does not include any functionality. The animation starts from blur with counting number from 0 to 100 and we can see clear image. Every time we refresh the page the animation starts. It’s all about playing with CSS and js. See the screenshot below.

Blur loading image1 1200x559 1


Html will be used for placing the image and text on screen. We are using free image from unspalsh website.

 <!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 

    <link rel="stylesheet" href="
    font-awesome/5.15.2/css/all.min.css" integrity="sha512-HK5fgLBL+xu6dm
    O8w==" crossorigin="anonymous" />

    <link rel="stylesheet" href="style.css">
    <section class="bg"></section>
    <div class="loading-text">0%</div>

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

blur loading

Blur loading project css

We will be using CSS for styling and blurring the image, fixing position, colour and text. See the code below.


@import url('');

* {
    box-sizing: border-box;

body {
    font-family: 'Ubuntu', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    margin: 0;

.bg {
    background: url(;
    position: absolute;
    top: -30;
    left: -30;
    width: calc(100vw + 60px);
    height: calc(100vh + 60px);
    width: 100vw;
    height: 100vh;
    z-index: -1;
    filter: blur(0px);

.loading-text {
    font-family: 50px;
    color: #000;
    font-size: 70px;
    font-weight: 400;

Blur loading project js

The javascript will be used for setting the time interval between 0 and 100. When user refreshes the page they must see the blur effect with counting numbers. This project is responsive from small to large devices. Check the js code below.


const loadText = document.querySelector('.loading-text')
const bg = document.querySelector('.bg')

let load = 0

let int = setInterval(blurring, 30)

function blurring() {

    if(load > 99) {
    loadText.innerText = `${load}%` = scale(load, 0, 100, 1, 0) = `blur(${scale(load, 0, 100, 30, 0)}px)`

const scale = (num, in_min, in_max, out_min, out_max) => {
    return(num - in_min) * (out_max - out_min) / (in_max - in_min) +out_min;

Although the code is provided in this tutorial. You can click the button below to get the source code of this project.