Page Loading Effects with jQuery
JQuery is really a powerful and handy JavaScript library. The page or content loading effect is very easy to implement in jQuery. Here’s a example to make your web page content display a fade in page loading effect. It will make your reader a shock impression. ![]()
The idea is simple ~
1. Create a div block with content hide
This div block is use to implement content fade in page loading effect.
<div id="page_effect" style="display:none;"> <!-- this content is hide, need jQuery to fade in --> </div>
2. jQuery fadeIn effect
Create a jQuery fadeIn effect when document is ready to display
$(document).ready(function(){
$('#page_effect').fadeIn(2000);
});P.S fadeIn() is the jQuery library build in function.
3. Demo
Complete jQuery codes to implement the fade in loading effect.
<html> <head> <title>JQuery Page Loading Effect</title> <script type="text/javascript" src="jquery.js"></script> </head> <script type="text/javascript"> $(document).ready(function(){ $('#page_effect').fadeIn(2000); }); </script> <body> <div id="page_effect" style="display:none;"> <h1>JQuery Page Loading Effect</h1> This is page loading effect with JQuery 1<BR> This is page loading effect with JQuery 2<BR> This is page loading effect with JQuery 3<BR> This is page loading effect with JQuery 4<BR> This is page loading effect with JQuery 5<BR> This is page loading effect with JQuery 6<BR> This is page loading effect with JQuery 7<BR> This is page loading effect with JQuery 8<BR> This is page loading effect with JQuery 9<BR> This is page loading effect with JQuery 10<BR> This is page loading effect with JQuery 11<BR> This is page loading effect with JQuery 12<BR> This is page loading effect with JQuery 13<BR> This is page loading effect with JQuery 14<BR> </div> </body> </html>
thanks for sharing…very helpfull
works perfect! thanks!
[...] the perfect Preload Page jQuery Script. After a rigorously searching different sites, I came across Mkyong’s “Page Loading Effect with jQuery“. I found that the code is very simple to work with [...]
Script works fine with single html, but when I add it in template and create other pages in Dreamweaver, it doesnt. It just shows blank space, althought it’s working in *.dwt file.
good work guys thnx for the tip
it’s nice and you can show it in center of an element using
$(“#report-pane”).ajaxStart(function() { var width = $(this).width(); var height = $(this).height(); $(“#report-loading”).css({ top: ((height / 2) – 25), left: ((width / 2) – 50) }).fadeIn(200); // fast fade in of 200 mili-seconds }).ajaxStop(function() { $(“#report-loading”, this).fadeOut(1000); // slow fade out of 1 second });
thank you
jQuery is complicated and simple at the same time. I must learn to use it…
Thanks !! Nice work…
Good trick.
But I more interested to use a jQuery plugin, such page pre-loader. But I never find a jQuery plugin to display percentage of page load of web data, same as gmail loader.
Good stuff – now I just need to find somewhere to use it!
Awesome trick! Thanks!
Thanks , nice trick
Great effect. love the look of it.
Is there a way to make it preload the images. if I hit ctrl+F5 then the fade in doesn’t work as it loads the images first.
If i then refresh with a simple F5 then the fade in effect works.
If you want to check out what I mean go to http://pumasocial.co.za/
Thanks in advance for any help you can give me.
Regards
thx it works http://alko.web.id/
how to make loading dots ?
loading dots? What you mean?
before page ready
show text loading…
Very nice. But wouldn’t the following be preferable?
$(document).ready(function() {$('body').hide().fadeIn(2000);
});
Advantages: no need for an extra tag; and works if JavaScript is disabled as our container element isn’t hidden via CSS.
Great comment, very useful!
that’s awesome! but is there a way to avoid the page flash loading right before it hides and fades in?
I like the script. Works perfectly. But I need to figure out a way to show the page if someone doesn’t have javascript turned on. I have not been able to figure out a way to continue without the function if the user has javascript turned off. Please Help. Thanks.
can any body help me in running a jquery code where in after a clicking ecah page on the menu bar the jquery code sholud run which will inturn run a insert query in php.
plz help on my email
amol.bhandari@lelesys.com
Great and Simple instructions, its always interesting to read about what jQuery has to offer
Thank you 
just what I’m looking for!
Thank you sir
I have used this to phase in an image (gif) and it works perfectly.
However, it does not work if I use it on an SWF file. Pehaps that is not possible or I am missing something ?
In any case, thanks very much for this – the technique and the time taken to explain it.
James
Sorry, i’m not familiar with SWF, hope someone can answer it, may be you can post your question in stackoverflow.com
There is some problem, if you have more DIV tags included and some of them are positioned “absolute” (in CCS declaration). In FF and Google Chrome is everything correct, but in IE 6/7/8 fade effect doesn’t work. Has anyone some idea how to fix it ?
[...] Page Loading Effects with jQuery JQuery is really a powerful and handy JavaScript library. The page or content loading effect is very easy to implement in jQuery. Heres a example to make your… [...]
[...] Page Loading Effects with jQuery JQuery is really a powerful and handy JavaScript library. The page or content loading effect is very easy to implement in jQuery. Heres a example to make your… [...]
cool, this is a informative post. i will definitely tweet this
Is there a way to make it like an array? Make modules load in an order 1,2,3,4,5,6… ?
Thank you so much for this script!
The idea will be wrap your content in order, and assign an order ID for each, then load it one by one with the timeout function.
this is what I came up with, it calls individual tags:
The alternate is this, it calls only items with the “crisco” class:
This is only for images with the “crisco” class:
Demo by clicking my name above
Hi, thanks for sharing your tips.
Is there a way to apply it to several divs in one page? So maybe a class rather than an ID?..
I tried Tim’s suggestion. But I’d prefer something that fades in all together, rather than sequenced, but able to apply it to many divs in one page.
Thanks very much.
[...] is http://www.mkyong.com/jquery/page-lo…s-with-jquery/ .. But this working at the page load..But i want this at the page unload & reverse order of [...]
i have problem to ie6…
Hello … Nice job!
But .. I have problems in Safari (4.0.5)
Some of my content becomes invisible after the page is opened.
When I resize my browser window – it works fine!?!
What is the problem – and it can be solved?
Send me email with the the following information : URL, print screen, steps of simulation.
Nice one, but not the one i was looking for. Also I would suggest to make display none with inline scripting just under that div, so that no-script will gracefully degrade your feature,there is no prob with $(‘body’).fadeOut(2000), also display:none can prevent page from loading some images, visibility hidden can help, ju]t comments
, keep rockin dude……
nice.. tThanks for this
Hi there,
I have not implemented this code yet but would the fade in only perform when the entire page is loaded?
I have a webpage using an large BG images.
thanks
D
I think that wrapping this function inside the same function is redundant
$(document).ready(function(){
$(‘#page_effect’).fadeIn(2000);
});
This should do the same thing.
Article updated, typo error, thanks.
Hi, I implement this exactly like you showed, but in Safari, my text fades in and then disappears. Any idea what’s wrong?
I am looking for the similar effect for scrolling of page same like mashable. Can you help me with that? I did try it using the jquery plugin but it started throwing blank page however I can see that all the content are loading well.
you should try digg digg
http://www.mkyong.com/blog/digg-digg-wordpress-plugin/
I am looking for the similar effect for scrolling of page same like mashable. Can you help me with that? I did try it using the jquery plugin but it started throwing blank page however I can see that all the content are loading well.
Makes my Firefox crash…
how’s this work for the NOSCRIPTers?
do not think it is possible to achieve with current technology
I mean how does it fall back if java script is turned off in the user browser?
google it “how to check if javascript disable”. If the javascript is disable, it will still display the whole content directly with no fade in effect appear.
No it won’t!!! This is AWFUL coding – if the user has javascript disabled, the inline style declaration of “display: none;” will still be there.
There are loads of ways to do this, but you’ve chosen the worst possible method to implement it.
So simple, but so helpful!
Thanks
Hello,
i have a problem in ie 7/8 ! The fading text transform and images too! It’s not nice. Do you have a fix for this problem ?
This demo is working fine in my IE8, the effect is exactly same with Firefox. Mind to share your code wit me?
Lovely. Just what I’m looking for. Thanks much.
nice work! it work for me!!!
Nice…!
Thanks.. very nice a tutorial..
Mkyong….
Thanks for this tutorial…
very-very help me on my application event my application using master page…
its realy working on me…
thanks a lot dude…
cheersss….
thanks, it’s good to know helpful to others
Thanks for this but I have one question, is it possible to load un html web page in a div with jquery ?
i am in secondary school and i havent learnt how to do stuff that advanced but i am realy intrested in it, i tried to do it but it dont seam to be working can you write a step by step instruction on how to make it work
thanks
1) download the jquery library (jquery.js)
2) Create a html file, copy and paste the html code above
Note: src is your downloaded jquery file location
3) Save the file as html file and open it with your favor browser.
Hi im fresher to webdev..gide me how to add dis effect to my pages…
You should append the html elements for the loading screen with JS so that users on devices that do not support JS/CSS won’t get the loading elements.
opppsss.. sorry i just tried the script and it’s awesome.. thank you very much…
love it.. will use this for my next web/blog project.. 
good to know this work for you.
thank you for this script, this is what i’m looking for..
But with 1 question:
can i add this script inside my first page, there’s a lot of images inside my web, and i was thinking about how long it’ll load my page?