• Stars
    star
    275
  • Rank 149,796 (Top 3 %)
  • Language
    CSS
  • License
    MIT License
  • Created about 13 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PreLoadMe, a lightweight jQuery website preloader.

PreLoadMe, a lightweight jQuery website preloader

PreLoadMe is a lightweight preloader for any webcontent. Powered by jQuery and CSS it is fully responsive and will run on all modern desktop- and mobile browsers with no additionals plugins. PreLoadMe displays a loading animation until the browser fetched the whole webcontent and will fade out the moment the page has been completely chached. Because the simplicity of PreLoadMe, it can be easily customized and adapted to your needs.

PreLoadMe displays a loading animation until the browser fetched the whole web content and will fade out the moment the page has been completely cached. Because the simplicity of PreLoadMe, it can be easily customized and adapted to your needs.

You can see a live preview here: PreLoadMe Live Preview

Implementation

PreLoadMe is jQuery driven. You will need to implement an up to date jQuery version and the corresponding JavaScript for executing the preloader. Add the following code right before the </body> tag.

<!-- jQuery Plugin -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.3.min.js"></script>

<!-- Preloader -->
<script type="text/javascript">
    //<![CDATA[
        $(window).on('load', function() { // makes sure the whole site is loaded 
            $('#status').fadeOut(); // will first fade out the loading animation 
            $('#preloader').delay(350).fadeOut('slow'); // will fade out the white DIV that covers the website. 
            $('body').delay(350).css({'overflow':'visible'});
          })
    //]]>
</script>

The CSS-Markup will help you style the preloader. Make sure to include it on your website.

body {
	overflow: hidden;
}

/* Preloader */
#preloader {
	position: fixed;
	top:0;
	left:0;
	right:0;
	bottom:0;
	background-color:#fff; /* change if the mask should have another color then white */
	z-index:99; /* makes sure it stays on top */
}

#status {
	width:200px;
	height:200px;
	position:absolute;
	left:50%; /* centers the loading animation horizontally one the screen */
	top:50%; /* centers the loading animation vertically one the screen */
	background-image:url(../img/status.gif); /* path to your loading animation */
	background-repeat:no-repeat;
	background-position:center;
	margin:-100px 0 0 -100px; /* is width and height divided by two */
}

Finally place the following HTML Code directly after the <body> tag.

<!-- Preloader -->
<div id="preloader">
	<div id="status">&nbsp;</div>
</div>

The outer DIV preloader will be called from the CSS file and will cover the entire website with a white DIV. The inner DIV status will show the loading animation. Also you should not forget to give your document a proper doctype. Otherwise the preloader might not work.

Using with AJAX requests

If you want to show preloader during AJAX request you can use the following CSS code.

#preloader {
	position:fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;		
	background-color:#fff; /* change if the mask should have another color then white */
	z-index:99; /* makes sure it stays on top */
}		

#status {
	width:200px;
	height:200px;
	position:absolute;
	left:50%; /* centers the loading animation horizontally one the screen */
	top:50%; /* centers the loading animation vertically one the screen */
	background-image:url(../img/status.gif); /* path to your loading animation */
	background-repeat:no-repeat;
	background-position:center;
	margin:-100px 0 0 -100px; /* is width and height divided by two */
}			

Your Javascript code will look like:

$("#status").fadeIn();
$("#preloader").fadeIn();
$.get(url, data, function(){
	$("#status").fadeOut();
	$("#preloader").fadeOut();
});

The source package contains all relevant files and a working demonstration.

Credits

Please support humans.txt (http://humanstxt.org/). It's an initiative for knowing the people behind a website. It's a TXT file that contains information about the different people who have contributed to building the website.

PreLoadMe: https://github.com/niklausgerber/PreLoadMe
Niklaus Gerber
Twitter: @niklausgerber
URL: https://www.niklausgerber.com
Location: Zürich, Switzerland

Download, Fork, Commit.

If you think you can make this better, please Download, Fork, & Commit. I'd love to see your ideas.

Donation

I love to create and I won't ask for repayment. If you appreciate my work and would like to support me I am sure you will earn some extra Karma points. Please donate.

More Repositories

1

Rapid-Bootstrap

Fluid HTML, CSS, and JS toolkit from Niklaus Gerber for rapid website developement.
CSS
50
star
2

Rapid-Bootstrap-V3

«Rapid Bootstrap V3» is my toolkit for kickstarting web-projects, apps, and more. It includes a basic set of CSS elements optimized for perfect typography, a super simple fluid grid system and all necessary JavaScripts to develop mobile friendly websites. «Rapid Bootstrap V3» is especially built for [Hammer](http://hammerformac.com). This nifty little tool by Riot can help you to build a static HTML site even faster. If you don't own a copy of hammer you will find everything processed in the «Build» folder.
CSS
40
star
3

NavLax

Fluid and mobile friendly navigation concept
CSS
37
star
4

monochrome

A fully responsive Kirby CMS theme
PHP
27
star
5

Protect-Kirby-CMS

This plugin will help you to password protect any Kirby CMS page.
PHP
21
star
6

FitMyVideo

A lightweight and easy-to-use CSS solution for fluid width for video embeds.
HTML
14
star
7

pure

Beautifully crafted minimalistic loading animations.
14
star
8

rapid-bootstrap-v4

«Rapid Bootstrap V4» is a toolkit for kickstarting web-projects, apps, and more. It includes the essential set of CSS elements optimized for perfect typography, a super simple fluid grid system and everything else necessary to develop mobile friendly content. It is optimized for speed and efficiency and will support all major desktop and mobile browsers. One of the cleanest and simples bootstraps you will ever get you hands on.
HTML
13
star
9

themis

A minimalistic and responsive Kirby CMS theme for photographers.
PHP
10
star
10

Bootstrap

Responsive HTML, CSS, and JS toolkit from Niklaus Gerber
4
star
11

rapid-bootstrap-v5

«Rapid Bootstrap V5» is a toolkit for kickstarting web-projects, apps, and more. It includes the essential set of CSS elements optimized for perfect typography, a super simple fluid grid system and everything else necessary to develop mobile friendly content. One of the cleanest and simplest bootstraps you will ever get you hands on.
HTML
3
star
12

responsive-google-or-bing-maps

If you are looking for an easy and fully responsive solution to embed Google or Bing maps on your website, you might want to try this CSS technique.
HTML
1
star