All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

Display Loading Image While Page Loads

Last Updated : Jul 1, 2023

IN - jQuery CSS HTML | Written & Updated By - Riya

In this tutorial we will show you how to display loading image while page loads using jQuery and CSS. You can also do this with JavaScript alone but in that case there is no animation because javascript does not support animation.

You may also like Display Preloading Image On Image Loading Using jQuery

Display Loading Image While Page Loads

To Display Loading Image While Page Loads it takes only one step:-

  1. Make a HTML file and define markup,script and styling

Step 1. Make a HTML file and define markup,script and styling

We make a HTML file and save it with a name page_loading.html

<html>
<head>
<script type="text/javascript" src="jquery.js">
<script type="text/javascript">
$(window).load(function() {
	$(".loader").fadeOut("slow");
})
</script>
<style>
.loader 
{
 position: fixed;
 left: 0px;
 top: 0px;
 width: 100%;
 height: 100%;
 z-index: 9999;
 background: url('loader.gif') 50% 50% no-repeat rgb(249,249,249);
}
</style>
</head>
<body>
<div class="loader">
</div>
<div>
This Is A Demo Of How To Display Loading Image While Page Loads
</div>
</body>
</html>

In this step we create a two divs one for loader and another for page content and then we use jquery window.load event so that when page loading completes loader disappear with fadeout animation.

You can use any animation you want. You may also like Display Progress Bar While Page Loads Using jQuery

Thats all, this is how to Display Loading Image While Page Loads. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

I hope this tutorial on show loading image while page loads using javascript helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Riya

A recent graduate with a Bachelor of Technology (B.Tech) in Computer Science from India. She is passionate about leveraging technology to solve real-world problems. With a strong foundation and experience in programming languages such as Python, Django, HTML, CSS, and JavaScript, java, php and have honed her skills through hands-on projects and coursework.

Follow Riya On Linkedin 🡪