QueryLoader – preload your website in style

230

There is always a minor problem when it comes to preloading image on a website. Nobody really has a full solution for it. There are a lot of preloaders available, but most of the time they only display the words: “Loading page” or have an animated image that spins. Why can’t there be a nice loading bar of some kind?
I’ve gotten a few request on how to make a preloader, or people asking me how to get all the images of a web page and preload them (even the images in CSS).

This preloader has it all. Loading bar, custom animations and getting all images included in the web page.

qloader

Download
Get the preloader script!
Example
See the preloader in action.

(a special shout out goes to Sieb of Siebdesign for coming up with the animation and the idea of building a preloader)

Download the source code here:
http://www.gayadesign.com/scripts/queryLoader/queryLoader.zip

View the example here:
http://www.gayadesign.com/scripts/queryLoader/

Example with percentage visible:
http://www.gayadesign.com/scripts/queryLoader2/ or download: http://www.gayadesign.com/scripts/queryLoader2/qL2.zip (thanks to Olivier Dumetz)

Features:

  • Preload a whole web page.
  • Preload a part of the page.
  • Gets all images, <img> tags and background-image of your CSS
  • Easy to implement.
  • Adjustable loading bar.
  • Tested in Firefox, Safari, Opera, Chrome, IE7, IE8 and IE6 (script will be ignored in IE6 though).

Implementation:

To implement this script you don’t need any Javascript experience. Just follow these easy steps:

1. Download the zipped archive.

2. Upload the contents to your webserver.

3. Place the following code in the part of your page:

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js'></script>
<link rel="stylesheet" href="css/queryLoader.css" type="text/css" />
<script type='text/javascript' src='js/queryLoader.js'></script>

Remove the jQuery part if you have already included the file.

4. Place this code at the bottom of your page:

<script type='text/javascript'>
	QueryLoader.init();
</script>

You are now done!

Customization:

If you only want one element / container to be preloaded you can setup a jQuery selector to only preload what you want.

Let’s say you have an element with an id. You only want the images inside that element to be preloaded. You can use the following code:

<script type='text/javascript'>
	QueryLoader.selectorPreload = "#idOfTheElement";
	QueryLoader.init();
</script>

Be aware that you can only preload a single element. So using a class selector could cause some problems.
To read more about selectors in jQuery you can read this page in the jQuery docs.

To adjust the animations of the loading bar, you can take a look in the following functions:
QueryLoader.animateLoader() and QueryLoader.doneLoad()

Adjusting these functions requires a bit of jQuery knowledge.

Any questions about QueryLoader and implementations can be posted in the comments below.

Good luck and happy developing.

Articles like this one

If you liked this article you can add this post to:


 

177 Comments

  1. dejunky said: October 2, 2009 at 8:37 am | Permalink

    Love it! I think I will test it out and let you know how I get on :-)

    good work dude!


  2. andi said: October 2, 2009 at 10:32 am | Permalink

    great work! thanks.
    i needed such a preloader a month ago, but it`s great having it now too.


  3. SIEB said: October 2, 2009 at 12:20 pm | Permalink

    Where did you get the idea… :P


  4. Gaya said: October 2, 2009 at 12:41 pm | Permalink

    @dejunky I’d love to see your version!
    @andi good luck! glad to be of service ;)
    @sieb a great designer from the netherlands ;)


  5. Fredy Munevar said: October 2, 2009 at 2:52 pm | Permalink

    very very awesome!!!… THAAANKS


  6. Felipe Lima said: October 2, 2009 at 4:01 pm | Permalink

    GREEEEATT!!!!
    Thanks a lot


  7. thanksjc said: October 2, 2009 at 4:03 pm | Permalink

    I unzipped the two folders from the download (CSS & JS) and upload the two folders to my root folder on the server. I then pasted the 2 scripts above in this post in the middle of my webpage and at the footer as well. However, I still can not see the loader working. Any ideas? The page to view it is at: http://www.genesisinvestmentassociates.com/

    Thanks ahead of time!


  8. Marco said: October 2, 2009 at 4:18 pm | Permalink

    Was already waiting for a new post – this absolutely made up for the waiting time, great script mate!


  9. michael said: October 2, 2009 at 4:25 pm | Permalink

    @thanksjc it looks like you didn’t correctly place the scripts. The code shown in point 3 is best placed in the section of your page. The code in point 4 is best placed at the bottom just before the closing BODY tag.


  10. michael said: October 2, 2009 at 4:26 pm | Permalink

    my comment should have read, “…best placed in the HEAD section…”


  11. Avram said: October 2, 2009 at 4:46 pm | Permalink

    Hello,

    I’m having similar problems: Loader is not working. Using latest jQuery (1.3.2). The url is http://www.dredovi.info

    JS Console says:
    Error: $(window).height is not a function
    Source File: http://www.dredovi.info/scripts/queryLoader.js
    Line: 103


  12. Gautch said: October 2, 2009 at 4:51 pm | Permalink

    I like it!
    But mine only loads about 75% of the way and stops.
    Any ideas?
    http://dj.gautch.com

    Thanks!


  13. Gaya said: October 2, 2009 at 4:55 pm | Permalink

    Wow! Thanks so much for the sudden interest and the comments people!

    @marco: thanks buddy! glad you liked it :)
    @michael: thanks for answering the question, that’s what I was about to say haha
    @Gauth: there seems to be a broken image on your site. it can’t be loaded so queryloader thinks it is still loading. the image is:
    http://gautch.com/DJ/css/img/12_col.gif (404 error)


  14. Avram said: October 2, 2009 at 5:02 pm | Permalink

    I have same problems. The url is dredovi.info and JS console says Error: $(window).height is not a function Source File: scripts/queryLoader.js Line: 103


  15. thanksjc said: October 2, 2009 at 5:03 pm | Permalink

    Thanks Michael, but I’m still having trouble. I hate to sound like the newbie and all, but I just can’t get it to work. I have moved the code in point 4 to right before the closing BODY tag, and put the code in point 3 at the beginning of the BODY section. Is this the right section for point 3? I couldn’t tell by what was written. I have however tried other sections of the page’s html but no luck either. Anyway, this script looks killer and I’ve been looking for one like this. I would love to see this working. Thanks.
    Page link: http://www.genesisinvestmentassociates.com/Our_Work.html


  16. HullDO said: October 2, 2009 at 5:06 pm | Permalink

    This is a great idea. Thanks for this.


  17. Gaya said: October 2, 2009 at 5:08 pm | Permalink

    @avram: have you included jQuery? Strange that it gives that error.
    @thanksjc: you have to put the code of step 3 inside your section (code) and the code of step 4 just before I hope it works now :)


  18. thanksjc said: October 2, 2009 at 5:15 pm | Permalink

    I have now put the code from point 3 into the head section of my page’s html and the from point 4 into the page’s html right before the closing of the body tag. Still no luck yet. Am I missing something? Do I have to edit any of the files from the zip I downloaded?

    Page link: http://www.genesisinvestmentassociates.com/Our_Work.html


  19. Avram said: October 2, 2009 at 5:19 pm | Permalink

    @Gaya: Yep, latest jQuery (1.3.2) is loaded just before your .js file.

    @thanksjc: As far as I can see, you’re getting same error in JS console as I am.


  20. thanksjc said: October 2, 2009 at 5:26 pm | Permalink

    @Gaya & Avram: QUOTE – “Yep, latest jQuery (1.3.2) is loaded just before your .js file.” This was stated above. I have that file uploaded to my server as well, but do I need to do something special with it in terms of this script to make it work. If so, that may be the issue for me because I have not touched any files, just cut and pasted the codes from points 3 & 4 and put them in my page’s html.


  21. Avram said: October 2, 2009 at 5:31 pm | Permalink

    @thanksjc: Again, as far as I can see, your jQuery is not loaded correctly. You have some HTML tags in SRC property of (jQuery) script tag. There should be plain URL of .js file.


  22. Gautch said: October 2, 2009 at 5:39 pm | Permalink

    @Gaya That worked! Thanks sooo much!!


  23. Gaya said: October 2, 2009 at 5:47 pm | Permalink

    @Gautch: great! good to hear
    @Avram: is there a possibility that you are running jQuery in no conflict mode? You’d have to adjust the script if that is so.


  24. Avram said: October 2, 2009 at 5:52 pm | Permalink

    I wasn’t using jQuery prior to your script on this website, but it seems that some other script is setting jQ to noConflict mode. Now I have placed $ = jQuery.noConflict(); before calling your init() function and it seems to work now, but it stucks at half. Probably I have some dead images. Will check that.

    Thanks for your help.


  25. Gaya said: October 2, 2009 at 6:03 pm | Permalink

    No problem! Let me know if it works after you fix things :)


  26. Avram said: October 2, 2009 at 6:15 pm | Permalink

    OK, jQ wasn’t working because of Prototype lib, which was loaded after jQ and your script (but before calling init() method). I have fixed that by assigning jQ noConflict to $. But it still stucks at half despite I have only one image on my page (logo.jpg, and it’s present, so no 404 err here). The other issue is – the page actually displays, and when it’s loaded, preloader is displayed. But this is normal (though not as it should be) as init() is called at the end of page, no?


  27. Avram said: October 2, 2009 at 7:22 pm | Permalink

    I can’t find out what’s the problem :(
    You can test it yourself by opening dredovi.info/?preloader

    And little suggestion: You could add some kind of debug mode which would display (below the progress bar) which file is being loaded at the moment? That way we could find and eliminate problems causing preloader to stop at certain point.


  28. Karar.A. said: October 2, 2009 at 7:27 pm | Permalink

    Very nice , just what I am searching for . thank you so much .
    btw very nice looking website :) keep the good work .
    best regards
    Karar!


  29. Barry said: October 2, 2009 at 7:38 pm | Permalink

    Works fine in Opera too.


  30. Ozh said: October 2, 2009 at 7:53 pm | Permalink

    Wow, just like the page transitions in MSIE </grin>


  31. Michael said: October 2, 2009 at 8:27 pm | Permalink

    Great! Works perfectly. Great Work done!!! Highly recommended.


  32. thanksjc said: October 2, 2009 at 9:04 pm | Permalink

    Still no luck here getting it to work. : (
    Looks great though and it will definitely bless a lot of people! Good work!


  33. Avram said: October 2, 2009 at 9:45 pm | Permalink

    Hello Gaya,

    I have looked a bit around the page with FireBug and found out that, for some reason, your preloader tries to load Google AdSense AD as IMG – have no idea why, as you have properly placed “*:not(script)” selector in your script :/


  34. orta said: October 2, 2009 at 10:29 pm | Permalink

    Good concept, I might give this a try.


  35. gautch said: October 3, 2009 at 4:50 am | Permalink

    Id like to know how to adjust the colors…


  36. devolved said: October 3, 2009 at 5:28 pm | Permalink

    Nice. Practical and purdy, as usual.


  37. Yogsototh said: October 3, 2009 at 5:36 pm | Permalink

    Hi, thanks, but it didn’t worked as expected. My web page had the time to show just before the black layer to appear.

    Nonetheless the idea was great, this is why I made my own ( I explain how at http://u.nu/8mue3 )

    The only difference is that I have to add a new ” at the begining of my source code.


  38. Yoosuf said: October 3, 2009 at 6:29 pm | Permalink

    Awesome work, Stumbling this post


  39. Matt said: October 3, 2009 at 6:33 pm | Permalink

    nice script works well, had minor issue with the script not being compatible with part of my flash animation, fixed that and it works perfect. thanks for sharing.


  40. Synaesthetic Studios said: October 4, 2009 at 4:42 am | Permalink

    This is freakin awesome!! I’ve been wanting a jQuery loader just like this for a while.

    I can’t figure out how to change the colors though! I’d appreciate any info on how to mess with that.


  41. Synaesthetic Studios said: October 4, 2009 at 4:46 am | Permalink

    Durr! I figured it out colors are all in the .css file!


  42. Jimmy Ngu said: October 4, 2009 at 8:41 am | Permalink

    Stops working if you clear the cache and hit refresh …

    But other than that, its totally awesome script !!!


  43. Crazy Frog said: October 4, 2009 at 10:32 am | Permalink

    This sux. It preloads to about 50%-70% and “hagns-up” on HTML5 pages with audio and video tags (de-facto self-preloadable/bufferable elements).


  44. Gaya said: October 4, 2009 at 12:58 pm | Permalink

    Hi all! Thanks for the overwhelming interest!
    I’ve been taking the comments in account and updated the script just now. Elements with a src attribute were loaded in QueryLoader but I restricted it to only “img” tags. I recommend that you download the new version.


  45. Gopal Raju said: October 5, 2009 at 4:49 am | Permalink

    This is exactly what I was looking for! Right on time!! Thanks!


  46. Zeal Murapa said: October 5, 2009 at 6:40 am | Permalink

    Can you create a wordpress plugin from this?


  47. Predrag Stojadinovic said: October 5, 2009 at 8:39 pm | Permalink

    @Avram, dredovi.info seems to work now, did you get the latest version or was it something else?


  48. Jens Mikkelsen said: October 6, 2009 at 8:38 am | Permalink

    Does it also preload flash objects ?


  49. Gaya said: October 6, 2009 at 8:55 am | Permalink

    @Jens: Nope, only images. can’t preload flash


  50. Loganathan said: October 6, 2009 at 9:54 am | Permalink

    Nice work… great and thanks a lot


  51. Dave said: October 6, 2009 at 2:59 pm | Permalink

    This seem to work really well, apart from a small flash of content before the preloader kicks in and hides the content. Any ideas why this happens and how it can be prevented.

    Example can be seen by loading any of the pages on my site (http://www.digitalslrphotos.co.uk)

    The first element is an image in the header, which I thought work force the loader to kick in, but as you can see, some of the text elements annd the header image are shown before being covered by the loader (at least they do in Opera).


  52. Dave said: October 6, 2009 at 3:25 pm | Permalink

    Nevermind – fixed the issue – it was a scrollTo script that was conflicting with queryLoader. Removed it and all is well. Great script.


  53. moabi said: October 7, 2009 at 10:09 am | Permalink

    amazing…great job


  54. Sascha said: October 7, 2009 at 1:48 pm | Permalink

    Is it possible to make it load only once?


  55. NickW said: October 7, 2009 at 10:53 pm | Permalink

    Hiya – I’d really like to use this but just can’t get it to work; I’ve uploaded the js & css files and added the script to the head and body of my page. Sometimes when I try and load the page it seems to go black for a split second, but mainly it’s just the same as before – lots of images loading one by one – very messy!
    I wonder if there’s a clash with other Javascript on my page, but all I’ve got is tool-tips – it’s mainly just html and css.
    The offending page is http://www.fluidmastering.com/gallerytestnew.htm

    I’m probably being ignorant – never used jQuery before…

    any help gladly recieved!

    ta,

    Nick


  56. BEBEN said: October 8, 2009 at 12:40 am | Permalink

    aku enggak paham, tapi bagusss…good good…nice to meet u..bai bai…dahhh


  57. Alex Talha said: October 8, 2009 at 4:19 am | Permalink

    Hello
    I am using query loader (Jquery) and startGallery (Moo Tools), only if I call the two libraries it conflicts, how to solve this problem with both?


  58. rikard said: October 8, 2009 at 8:53 am | Permalink

    I’m experiencing something strange, when I apply the script to my page it says, “ie is null” (line 46).

    This is both on Firefox 3.5.3 and Safari 4.0.3 on the Mac.

    The timeout isn’t meant to be triggered for non IE browsers, right?


  59. rikard said: October 8, 2009 at 8:58 am | Permalink

    To my above comment…

    Just noticed the same thing happens to your demo page which works fine.

    Problem is, the loader gets stuck when I try it on my page, so I thought it was related to the ie error thing. Seems like I was mistaken.


  60. steveg said: October 8, 2009 at 5:47 pm | Permalink

    What about:

    overlay: “”,
    loadBar: “”,
    preloader: “”,

    Can u explain how can we use this?


  61. Gaya said: October 8, 2009 at 6:08 pm | Permalink

    Thanks all for the comments!

    @NickW:
    I have no idea. maybe you should check your CSS/HTML

    @Alex Talha:
    You can try and convert my script into no conflict mode.

    @rikard:
    Do you have a broken image on your site?

    @steveg:
    This variables are necessary for the script to function. various dom elements will be set to those variables.


  62. silvy said: October 8, 2009 at 7:39 pm | Permalink

    bien même très bien ,


  63. MC said: October 8, 2009 at 9:43 pm | Permalink

    Hey,
    Thanks for queryLoader, it’s great.
    Been trying to modify it though without success. How could I go about just having the first part of the animation where the line goes from left to right but not having the whole div change colour (the last part of the animation)? So I kind of get left with a minimal progress bar if you get what I mean.
    Thanks again for sharing this!


  64. Gaya said: October 9, 2009 at 12:11 pm | Permalink

    @MC:
    Look in the .doneLoad function. you can change the animation there. (top, height animation)


  65. Alex Talha said: October 9, 2009 at 11:15 pm | Permalink

    did not understand, can you explain? I’m still new to the subject. what would be the method to work


  66. Stefan said: October 10, 2009 at 3:13 am | Permalink

    This is pretty darn cool! You really have some really unique scripts here on your blog.


  67. Justin Sainton said: October 10, 2009 at 8:15 am | Permalink

    For anyone having an impossible time getting this working without a quick flash of content showing first – here’s what I found. I have SEVERAL plugins on wordpress that throw javascripts up to the header and footer, so I thought for sure it must have been one of those…debugged one by one and it wasn’t. My culprit was the Google Analytics code I had in my footer. Mu guess is it was the try/catch code, but I put it in the header and it worked just fine.

    Hope that helps someone!


  68. Martin said: October 10, 2009 at 6:24 pm | Permalink

    Wondering why you chose to make IE6 ignore the script? In any case, one of the nicest preloaders I have seen, good stuff. Will definitely use it on some of my sites.


  69. Jonas said: October 11, 2009 at 7:51 pm | Permalink

    Great stuff my friend!


  70. Botnary said: October 14, 2009 at 10:21 am | Permalink

    Great stuff !! i like it :) but when i installed it on my web site i saw that QueryLoader start his animation after page is loaded and i already see the page content :) it’s waiting one sec and then animate :) it’s possible don not show page content before QueryLoader start his animation ?


  71. Botnary said: October 14, 2009 at 10:29 am | Permalink

    problem is fixed :D i removed browser cache :) and now content is visible after QueryLoader animation.. cool !


  72. Ortwin said: October 16, 2009 at 12:48 am | Permalink

    Is it possible to show a loading image instead of the ‘loadingbar’ and how can we implement that?


  73. florent said: October 16, 2009 at 3:18 pm | Permalink

    Thanks for this pluging, but what about Google Chrome compatibility’s ? Not work for me… Any ideas please ?


  74. Oliver Mezquita said: October 18, 2009 at 1:15 pm | Permalink

    Nice tip. I’ll try it out and check how it works…


  75. oliver said: October 18, 2009 at 9:25 pm | Permalink

    I know I’m missing something as well. I’ve placed the code where I understood it should go based on the tutorial you have above. then I checked the source code of the example, just to make sure. i’ve done all the tweaking i know to do but the preloader gets bypassed and goes straight into the site, showing the 30-some-odd items remaining. help?


  76. Frankie said: October 19, 2009 at 8:57 am | Permalink

    Hey ! :-)

    Your script works fine ! Without a problem ! keep up your fresh work ;-)

    Question at the jquery Pro’s in here:
    Is it better to load the script at the bottom of the body or in the header ?

    Greetings,
    Frankie


  77. Gaya said: October 19, 2009 at 10:06 am | Permalink

    Thanks for all the comments!

    @Frankie
    It might be better to load it at the bottom, but that goes against a lot of people’s work flow. You can do whatever you’d like :)


  78. veeru said: October 20, 2009 at 3:33 pm | Permalink

    Hey

    This is really cool.I am having small problem with query loader in chrome and IE7 but works really great in firefox ,IE8.

    It does not load (leaves out small portion on left side of page) entire window when loading in the chrome and IE7.Can you please help me with that issue.

    Thanks,


  79. veeru said: October 20, 2009 at 8:00 pm | Permalink

    It’s working now.

    Thanks


  80. alba said: October 21, 2009 at 6:08 pm | Permalink

    Hi !
    Thank you so much for this poste, exactly what i needed, but i have a kind a problem between html and php pages : html works but not php ?? can you help me please ? i’m refounding my website to get jobs this winter …


  81. alba said: October 21, 2009 at 6:17 pm | Permalink

    sorry
    just fake links make stop the preload …
    thx again


  82. Leo Caseiro said: October 21, 2009 at 8:37 pm | Permalink

    Hi, use jQuery.browser method on your script
    Know -> http://docs.jquery.com/Utilities/jQuery.browser

    I replace your code to
    ieLoadFix: function() {
    if(jQuery.browser.msie){
    while ((100 / QueryLoader.doneStatus) * QueryLoader.doneNow < 100) {
    QueryLoader.imgCallback();
    }
    }
    },


  83. egonomico said: October 22, 2009 at 7:28 am | Permalink

    Thanks for this preloader, I’ve just tested it and it works on every commonly used browsers out there. Great work!

    Cheers :)


  84. Gaya said: October 22, 2009 at 8:16 am | Permalink

    Glad it is working for everyone!

    Thanks for the tip Leo! I saw that browser functionality a few days ago haha. Was browsing a cheat sheet and basically hit myself in the head for not using it.
    Thanks for pointing this out, will surely use it in the future.


  85. gabriel said: October 22, 2009 at 4:10 pm | Permalink

    very nice, very nice


  86. kisquian said: October 25, 2009 at 10:49 pm | Permalink

    Hi..

    any solution to use this effect in IE6-??

    Sory my english suck,

    cheers


  87. Luis said: October 27, 2009 at 7:04 am | Permalink

    i got an error in firefox and chrome

    ie is null
    [Break on this error] if (ie[0].match(“MSIE”)) {\r\n

    how i fix it pls!


  88. Remi said: October 27, 2009 at 10:43 pm | Permalink

    Hi

    I have used your preloading technic at http://www.highlevelmedia.es , it is quite handy thanks for sharing

    It flicker a bit in safari on Mac, (showing content shortly then the preloader, i have to see why.)

    Thanks again


  89. Urban said: November 6, 2009 at 11:02 am | Permalink

    Hi,

    It’s a great script! But I have som issues in IE7. The content behind the preloader shows quickly before the preloader starts to preload.

    How can that be solved?


  90. Mike said: November 6, 2009 at 6:32 pm | Permalink

    I noticed that someone else had issues with scrollTo. I have a site that requires the flesler (http://flesler.blogspot.com/2007/10/jqueryscrollto.html) jquery scrollTo plugin. Any idea what the issue may be? I’m new to jquery, but any help would be appreciated. I’m also having the same issue as Urban, in that the site shows before the preloader in IE, but this may be an issue with scrollTo.

    Thanks


  91. jr said: November 9, 2009 at 1:08 am | Permalink

    thanks so much. as mentioned above, this script came out @ just the right time!

    kudos =)


  92. CW said: November 14, 2009 at 10:04 pm | Permalink

    This is such an elegant loader, but I’m having some trouble getting it to pre-load a CSS-specified background image.

    Example here: http://somewherenevertraveled.com/beta/


  93. kotatenk said: November 17, 2009 at 12:41 am | Permalink

    Love this. Tried this and worked on all platform. Bravo

    youbelongwith.us


  94. fazrul said: November 18, 2009 at 3:13 am | Permalink

    oh,you are my hero..haha! i really love this tweak..thanks for sharing sir!! it make my page look more stylish..thanks again..it’s so easy to apply it instead..but the result..WOW!


  95. Uzair Khan said: November 18, 2009 at 12:05 pm | Permalink

    Brilliant plugin Gaya…I was wondering if there’s a way for us to specify not to load content inside a particular element? Like say load everything inside the body but leave any images inside the image div/block?


  96. Gaya said: November 18, 2009 at 1:06 pm | Permalink

    In the code, you can find several places where jQuery tries to find elements.
    On line 59 you see a part with *not(script), make this: *not(script, .class_name_that_needs_to_be_ignored)
    Hope this will work for you!


  97. aiwazz said: November 19, 2009 at 5:00 pm | Permalink

    I just wanted to say thank you so much, finally a preloader that does it the way i had envisioned but didnt but the effort into mustering up! I was wondering, I am noticing the occasional stall at 75% in my firefox only, but this is a browser related thing as my firefox has always acted strangely when I am coding with dynamically resized images that utilize a simple php image resizer (probably one of my plugins). If I ctrl f5 the page it will load fine, but after a few page loads, the 75% hang again. Would it be too difficult to load a failsafe, basically a timeout parameter? These preloaders can be dangerous in that in dynamic pages, if something goes wrong imagewise at some point, this puppy may just hang and effectively lock out your site. A timeout parameter that could be set would give that assurance that, if after lets say 10 seconds of trying, no matter what the page will be revealed. I will look at how to do this, but what do you think? Again, awesome work!

    sam


  98. aiwazz said: November 20, 2009 at 3:27 am | Permalink

    ok, added my own little timeout in your animate loader function, works for me. Just security in case any images ever break in my dynamic site. thanks, very nice script.


  99. saurabh rai said: November 22, 2009 at 9:45 pm | Permalink

    urgent help needed. i used the your preloader script on my website http://www.mec-holdings.com, works fine with firefox.

    cannot load page error in IE7! how should i resolved it, please email me at rai@bold.co.in

    Thanks!


  100. Anthony said: November 23, 2009 at 8:50 pm | Permalink

    Hey! I’ve been using this and it works great, fantastic work. The only problem I’m having is it seems to hang at around 90-95% for Google Chrome users. Everything is set up properly on my end, and the Chrome users can, for some reason, see the entire thing properly if they view the example hosted here.

    I got the debug from one of their browsers, and it looks like it is hanging here:

    if (ie[0].match(“MSIE”)) {

    I’m very new to jQuery so I’m hoping you can help me out. Thanks!


  101. Uzair Khan said: November 24, 2009 at 12:02 am | Permalink

    Much appreciated. I am facing this other problem with IE where the preloader rushes to the end without actually preloading all the images? Any hints as to what might be causing that?


  102. Avinash said: November 24, 2009 at 6:24 am | Permalink

    This lib works for my site but with one small error – it loads content once and then it excutes pre loader. what can be the possible reason ?

    Thanks


  103. yashmistrey said: November 25, 2009 at 9:08 am | Permalink

    Hello friend,
    Gr8 work, done.
    i am doing a project, but this is not running in my website, see
    http://makemycreative.in

    somebody tell me plz..

    Regards
    Yash


  104. xRommelx said: November 27, 2009 at 7:31 pm | Permalink

    thank you a lot bro, is a really amazing plug-in, this is what i am looking for


  105. Orgoa said: December 1, 2009 at 7:33 am | Permalink

    Is the “IE is null” issue ever going to be answered?


  106. Cyril said: December 1, 2009 at 4:11 pm | Permalink

    Hi,

    Thanks for your plugin. I have only a warning in IE8 :

    HTML Parsing Error : Unable to modify the parent container element before the child element is closed (KB927917)

    If I desactivate your plugin it works any idea ???


  107. Matt Bloomfield said: December 1, 2009 at 10:31 pm | Permalink

    Hi,
    I have this loading bar working fantastic in IE but when i view my page in Opera or Firefox it freezes at 95% and doesn’t show the page
    Really need urgent help
    Many thanks in advance
    Matt


  108. husky said: December 2, 2009 at 2:46 am | Permalink

    is it possible to insert an image in to this? possibly also delay the start to be able to give enough time to see the image.


  109. Senthil said: December 4, 2009 at 12:13 pm | Permalink

    This one rocks ! Easy to implement. Works fine in FF. In IE7, the content appears first and goes off in a flash with the pre-loader coming up. Still trying to resolve this content flash ! any ideas suggested ?

    Matt,

    If this freezes in FF at 95%, check your CSS/HTML for any image url attribute which may be pointing to an image which doesn’t exist


  110. Senthil said: December 4, 2009 at 12:15 pm | Permalink

    Husky,

    Modify the queryloader css, QAmt with background image option.


  111. Senthil said: December 4, 2009 at 12:20 pm | Permalink

    Orgoa,

    Replace the code which detects IE in ieLoadFix function with this bit and you shld not see IE is null.

    if($.browser.msie) {
    ….
    }

    Hope Jquery is using $ else use the no conflict stuff.


  112. Gaya said: December 4, 2009 at 1:59 pm | Permalink

    Hey Senthil, Thanks for the comments and solutions! I think I’ll be update the script shortly with the fixes you’ve given!
    I’ve tried to ignore flash objects, but they are sometimes hard to detect.
    Thanks again!


  113. Senthil said: December 4, 2009 at 3:35 pm | Permalink

    Gaya,

    The flash bit (not a flash object !) – the screen spits the content first before the spawnloader comes to action which is visible in IE !

    Try putting an alert before

    QueryLoader.spawnLoader();

    and view it in IE. You can see what I meant.

    I overcame this problem using appropriate CSS viz. hiding the content until animate loader is called where i have placed

    $(QueryLoader.selectorPreload).css({visibility:”visible”});

    Also, in your next release you can use the following to kick out IE6- browsers !

    if(($.browser.msie)&&($.browser.version.substr(0,1)<7)){
    return false;
    }

    There can be a better solution but this fits the bill for me to move fwd in my project.


  114. Remi said: December 5, 2009 at 2:31 am | Permalink

    Thanks Gaya

    this ia a really good project


  115. Joachim said: December 8, 2009 at 1:13 pm | Permalink

    This is the biz-niz !!!


  116. Melvin José said: December 10, 2009 at 12:14 am | Permalink

    Thanks man! This is brilliant.
    Used it on my soon to be new website.
    http://www.artelix.nl/nieuw


  117. Arek said: December 10, 2009 at 11:31 am | Permalink

    Everything works great. Thanks


  118. Justin said: December 10, 2009 at 10:42 pm | Permalink

    Thanks for the script!

    Any way to make the pre-loader only animate once?
    I don’t want to see it every time I go to my home page…

    Any ideas?

    Thanks in advance!


  119. ML said: December 13, 2009 at 7:59 pm | Permalink

    Looks nice.

    1. I wish it could preload JS files as well
    2. There’s a problem in IE8 — if I navigate to http://site/folder/ IE throws an alert (“unable to open the Internet site….”). If I hit “refresh”, it loads it just fine. No such problem in FF..


  120. Vycka said: December 14, 2009 at 12:37 am | Permalink

    Nice…but i have one question. Does it work with an iframe on the website? At least not for me, but I am not clever one with jQuery..


  121. DaBen said: December 15, 2009 at 12:00 pm | Permalink

    hi Gaya,
    Thaks for your work..!
    I still have this problem : “IE is null”
    I’m not a jquery specialist so…it’s little hard for me!
    I’m using soundmanager on my site, rollover menu and slide effect…maybe it’s too much?!!
    anyway, if you’v got the solution : it will be a nice christmas present!!
    Here is what i’ve got in firebug/firefox :
    ie is null
    anonymous() (line46)
    queryLoader.js() (line41)
    if (ie[0].match(“MSIE”)) {\r\n (line46)
    Thanks for help


  122. Gian said: December 17, 2009 at 12:32 pm | Permalink

    I’m working on a project. I wonder if is it possible to make it load only once?


  123. Elliot Lings said: December 20, 2009 at 11:57 am | Permalink

    Is the script open source?


  124. Rino said: December 21, 2009 at 8:10 am | Permalink

    Hey there,
    wonderful stuff, I wonder if this could work with $(“#whatever”).load ?

    A photo gallery, for example, might trigger a .load when the user clicks on a photo category, something like

    $(“ul#photo_categories li a”).click(function(){
    load_url=$(this).attr(“href”);
    $(“#photos_container”).load(load_url,function(){
    // load callback… QueryLoader might be here maybe? :)
    })
    })

    It would be great to have the images loaded through the jquery .load – and make sure the users doesn’t see them until they are completely loaded.

    Is it possible? Let me hear what do you think about it


  125. jelm said: December 21, 2009 at 8:36 pm | Permalink

    Thanks alot, you saved my day!


  126. Seba said: December 25, 2009 at 7:00 pm | Permalink

    It doesn’t work! I don’t know what do do !
    help me please :) !
    thanx


  127. PainFreePc said: December 29, 2009 at 7:42 pm | Permalink

    if the above did not work for you try this found at Web Hosting Talk: http://www.webhostingtalk.com/showthread.php?t=186215

    ——————————————————————

    function showpage() {
    document.getElementById(‘loader’).style.display = “none”;
    document.getElementById(‘main’).style.display = “block”;
    }

    Some preloading content here

    Main Content Here

    ——————————————————————

    see it working at: http://www.painfreepc.com


  128. damir.t@me.com said: January 3, 2010 at 1:44 am | Permalink

    Damn dude, so simply and yet functional. Props!


  129. kene ilaçlama said: January 4, 2010 at 1:52 pm | Permalink

    best regards… thanx for samples… perfect code :)


  130. Charly said: January 4, 2010 at 6:00 pm | Permalink

    I am testing this script on my page http://psdxhtmlycss.com

    It works perfectly.


  131. Aias said: January 8, 2010 at 3:48 am | Permalink

    how would i use this on a php page?
    by putting it in the header.php and the footer.php?

    thanks for the clean looking script!


  132. James said: January 10, 2010 at 2:23 am | Permalink

    Hi, I really love this script! But, I’m having the problem a few others are having, where part of the page is showing before the loader kicks in.

    I’m running it in a php page, with the loader in the header.php, and the other part in the footer. I can’t figure out the issue.

    The website is here: http://www.kilowattsmusic.com/blog/

    Any ideas?


  133. Gattinara said: January 11, 2010 at 2:15 pm | Permalink

    Hi, and thanks for the useful tutorial.
    I apologize me for the grammatical errors, but I write from the italia – using an automatic translator;
    it would return Me useful to know whether to bring some changes to the js that allows not to visualize the preload when the elements of the page have already been loaded; of default the effect always departs, also to loading already happened in precedence.

    Thanks still for any future replica.


  134. dgib said: January 12, 2010 at 9:37 pm | Permalink

    this loader starts to load in Safari then stops a 96%. what is the porblem?


  135. Andrew said: January 17, 2010 at 8:10 pm | Permalink

    Hey great work.
    Someone has solution for this to work with css shorthad backgrounds also ? it expects background-image and so on. Hardly use any of those lately. Would be great if it detect my background:#color url() repeat pos;

    Thanks


  136. Gaya said: January 18, 2010 at 9:11 am | Permalink

    @Andrew: I thought that worked. I will look into that some time later.


  137. Krato said: January 18, 2010 at 11:03 am | Permalink

    Hi, I get an errror in line 46.

    if (ie[0].match(“MSIE”)) {

    Said me: Cannot read property ‘0′ of null

    Can you help me?

    Thanks.


  138. Krato said: January 18, 2010 at 11:24 am | Permalink

    And how can I change the js, to put a Image Liaging instead the line and a simple fadeOut when finish?

    Thanks!


  139. Joan said: January 26, 2010 at 1:44 am | Permalink

    muy bueno :)


  140. Jelm said: January 26, 2010 at 11:58 pm | Permalink

    Hi,

    Is it possible to not do the animation if it once loaded before ? I see in the demo that it starts at 100% if you reload the page. Thx.


  141. James said: January 28, 2010 at 12:04 am | Permalink

    Thanks for this great script Gaya.

    I got a problem with script. Sometimes I see the page with the unloade images than the QueryLoader shows up and sometimes the script works well. Could please kindly guide me trough this situation. I’ve exactly did the same on your tutorial but nothing changes. This is an ASP page and I am using a database conection and calling queryLoader.js trough another ASP page. But I have tried so many things I directly loaded I changed the place of the script but nothing changes. As I see @Thanksjc had the same problem and couldnt solve …
    Looking forward to your reply.

    Again Great Job !


  142. uls said: January 31, 2010 at 3:04 pm | Permalink

    Hello, is there a way to use this with full flash page?


  143. Vassilis said: January 31, 2010 at 4:52 pm | Permalink

    Hello,
    I have a problem with the preloader. I’m using it in a dynamic webpage. If there is a broken image the loader doesn’t finish, therefore the webpage cannot finally open. Is there any way to force stop the loader in such cases? Thanks a lot in advance.


  144. entiene said: February 1, 2010 at 4:12 am | Permalink

    Hello,

    Great script. Perfect for a project I’m working on at the moment. One caveat: The script is working for me in all browsers with the exception of IE.

    http://www.jimmacroberts.com/

    It simply shows ‘0%’ and stays there… if you hit refresh, for some reason it then goes to 100% and displays the gallery..

    Any help would be appreciated.


  145. Manuel said: February 1, 2010 at 2:50 pm | Permalink

    It working great for me in Firefox but in IE7 the loading frame appears below the content. I mean the progress bar and the black frame appears below the main content instead of appearing over the content of the page.

    Is anybody having the same problem?

    Great work!!


  146. oskar said: February 5, 2010 at 8:42 pm | Permalink

    manuel, yes, i have the same problem.

    it working in firefox y chrome, but don´t work in ie7 and ie8.

    the website charge normally, ignoring jquery.

    thanks


  147. ossian said: February 8, 2010 at 1:23 pm | Permalink

    can someone please tell me in simple-speak, how to adjust the code and stop the site flashing/displaying before the loader kicks in? thanks….


  148. Parvez said: February 8, 2010 at 7:23 pm | Permalink

    Really great idea :) i’m going to use this on my site :) Best of luck


  149. MitchMontoya said: February 8, 2010 at 8:55 pm | Permalink

    Many thanks for this and for your work and great ideas!


  150. oskar said: February 8, 2010 at 9:36 pm | Permalink

    gaya, don´t work in ie? mozilla anda chrome work pefectly, i don´t understand why not in ie…………………………. heeeeeeeeeeeeeelp me , pleaseeeeeeeeeeeeeee!

    ;D , thanks


  151. dell said: February 9, 2010 at 10:55 pm | Permalink

    Great script, placed it on a page, uploaded it along with the .js files, worked fine except it would not allow a jQ slider on the test page to function. However, for a pre-loader its great. Thanks for sharing I will make use of this. I’m no expert, mostly a novice but enjoy playing around and hopefully learn something to boot. As for it not working in IE – heck not much of anything seems to work well in IE from what I’ve seen.


  152. Luiz Homero said: February 10, 2010 at 4:00 am | Permalink

    Very Very Nice ! Thx Soo Much !


  153. muhammadiq said: February 10, 2010 at 7:47 pm | Permalink

    this is the Preloader which can show me that there’s something wrong on the page !, if you guys experiencing stuck on this preloader, it means that there’s something on the page that is not loaded / wrong link or something….

    Im waiting for some good improvement in near future :)

    ps:
    can you explain how to use this vars ?

    overlay: “”,
    loadBar: “”,
    preloader: “”,
    items: new Array(),
    doneStatus: 0,
    doneNow: 0,
    selectorPreload: “body”,
    ieLoadFixTime: 2000,
    ieTimeout: “”,

    kind regards,

    good Gaya !!!


  154. Reinaldo Nascimento said: February 11, 2010 at 5:36 am | Permalink

    Hi Gaya, I’m having a problem with the preloader in IE8. It is showing the percentage apparently normal, bu it does’n load all the images of the site.

    It seems that the site “http://www.highlevelmedia.es” has the same problem.

    Any idea?

    Thanks, the script is realy awesome.


  155. Joseph Saade said: February 11, 2010 at 6:11 pm | Permalink

    thanks for the above script, during my implementation, I added some more functionalities, I will host it on google code when it is back online (they are doing maintenance now):
    //jquery image loader based on QueryLoader by Gaya Design
    //author: jsaade
    updates & fixes:
    - supports custom arguments no need for external CSS
    - can have several loaders/divs being loaded running not limited to only one
    - if the div itself has a background-image or if it is an image it is now taken into consideration.
    - resize when window is resized.

    arguments:
    - the id of the div, if not defined it is set to the body
    - the color of the overlay that should hide the content while its being loaded
    - an object defining the options to be used:
    - overlayColor: hex
    - userCallback: function to be called when the loader is done
    - showProgress: true/false
    - showProgressText: true/false
    - progressColor: hex
    - textColor: hex
    - textSize: in px
    - loaderPosition{top%,left%} => repositions the loader according to the overlay

    NB:
    - if there is a flash element, its wmode should be set to transparent, else it will be visible ontop of the overlay (might fix it using js soon).
    - make sure the div you are loading is visible else, its dimensions won;t be correct.

    Usage Example:
    1-
    var loader= new Loader(“#content”, {userCallback:showContent, showProgress:true, showProgressText:true, textSize:15});
    loader.Start();

    2-
    var loader= new Loader(“#content”, {userCallback:showContent, showProgress:true, showProgressText:true, textSize:15, loaderPosition:{top:20,left:50}});
    loader.Start();

    the object has a Start fnction actually start the loading process.
    it will get all the images and background images, add them to a hidden div and after
    they are all loaded, call the doneLoading function


  156. Joseph Saade said: February 12, 2010 at 10:16 am | Permalink

    http://code.google.com/p/jloader/


  157. Gaya said: February 12, 2010 at 11:21 am | Permalink

    Thanks for sharing Joseph! Will spread the word :)


  158. Stewart Amgwert said: February 12, 2010 at 8:02 pm | Permalink

    Link to the .js that has percentage numbers should be http://www.gayadesign.com/scripts/queryLoader2/qL2.zip


  159. Michael said: February 13, 2010 at 8:14 pm | Permalink

    Just curios, is there any kind of license for using this script?


  160. MAE said: February 15, 2010 at 3:04 pm | Permalink

    is there any possibility to add a cookie after the loading has been done ?


  161. Scott said: February 16, 2010 at 4:16 pm | Permalink

    I really like this script and seems to work well in Firefox but, in IE, Chrome, and Safari it appears that the page loads for a second and then the overlay, then the progress bar… my site is not graphics heavy at all but it seems to defeat the purpose to load the page then the overlay… check it out http://www.cameronstreet.ca


  162. James said: February 17, 2010 at 4:07 pm | Permalink

    Hi,

    Sorry to be a pain in the ass, but I followed the instructions and it doesnt seem to work correctly on my site. The link is here:

    http://zombiemod.com/sm/home.html

    It just displays a black page. Can you let me know what is wrong?


  163. Dusty said: February 17, 2010 at 6:56 pm | Permalink

    Is there a way to just preload a page’s content and display it as quickly as possible without the preload animation? I just don’t want my viewers to see the pages building. Once everything is cached, there’s no problem. It’s just on first load where the building occurs.

    Thanks,
    Dusty


  164. aleks said: February 18, 2010 at 9:14 pm | Permalink

    very nice script!

    i probably recommend not to preload the whole page (if isn’t a gallery page, lol), i suggest just a div only :D

    QueryLoader.selectorPreload = “#diviWithImg”;
    QueryLoader.init();


  165. Joseph Saade said: February 22, 2010 at 3:03 pm | Permalink

    @Scott
    it depends on your code, make sure the is not falling inside a div code by mistake.
    In addition, what you can do is display the overlay manually on the page before you do anything. then hide it when the loading is done.


  166. Bret Bouchard said: February 22, 2010 at 4:30 pm | Permalink

    Sweet, very handy


  167. shoaib hussain said: February 22, 2010 at 6:08 pm | Permalink

    this is just awesome,now my pages can be loaded a bit faster.thxn a lot


  168. Karl Francisco Fernandes said: February 26, 2010 at 12:44 pm | Permalink

    I had a look at your demo. What I don’t understand is that if the call to initialise the preloader comes just before the closing body tag, how does the preloader do its thing before the pages/images load?


  169. thehalvo said: February 27, 2010 at 3:32 am | Permalink

    thanks @JustinSainton. Your solution to move the Google Analytics code into the header worked great. Got rid of that “1 second” flash before the loader starts.

    @Gaya you should really include this into the intro to the article.


  170. astrit said: March 1, 2010 at 7:23 pm | Permalink

    why i cant just load the page at all just it stops to the 80 % ore something like this :S:S


  171. Rodrigo said: March 2, 2010 at 7:52 pm | Permalink

    the function ieLoadFix, gives a js error on mozilla, update the if statment to:

    if (ie[0].match(“MSIE”) && ie != null) {

    and the error will not popup.

    Great script man! Good Work! Keep on going!


  172. dean said: March 3, 2010 at 3:49 pm | Permalink

    Looks awesome! just have a minor problem in Safari. It only loads to say 70% then just stops. Did anyone encounter this?


  173. Web Guru said: March 4, 2010 at 2:27 pm | Permalink

    A nice & cool find for myself. Thanks mate.


  174. Gavin said: March 7, 2010 at 1:27 pm | Permalink

    Is it just me or does it not load properly in IE8? The demo runs the progress bar and then when the page loads not all the images are loaded. Working perfect in firefox though. Any thoughts other than IE is junk?


  175. aurelienG said: March 10, 2010 at 10:05 pm | Permalink

    Used on my website it works perfectly ! Thanks !


  176. tungee said: March 11, 2010 at 12:38 am | Permalink

    Why does it reloads on my Php-site each time i click to an internal link????????
    I love this but i cant use it!
    Any help?
    I thought i preloads one time ?


  177. Karl said: March 12, 2010 at 9:21 am | Permalink

    I really don’t understand why it does not work. Could anyone look at the (simple) source and help me?

    The page was working fine until I inserted the script. I now get an error message.

    Many thanks for your help


Leave a Comment

Your email is never shared. Get your own avatar with gravatar! Required fields are marked *

*

*



53 Trackbacks

  1. By Preloader jquery » Web Design on October 2, 2009 at 1:32 pm
  2. By mckabi's me2DAY on October 2, 2009 at 11:51 pm
  3. By links for 2009-10-02 « Mandarine on October 3, 2009 at 5:19 am
  4. By Ajaxian » QueryLoader, a full page preloader on October 5, 2009 at 6:38 pm
  5. By links for 2009-10-05 | Digital Rehab on October 6, 2009 at 1:15 am
  6. By Pluguin jquery: QueryLoader - Desen Web on October 6, 2009 at 7:19 am
  7. By QueryLoader, a full page preloader on October 6, 2009 at 10:00 am
  8. By HTML preloader using jquery « on October 6, 2009 at 2:45 pm
  9. By Recopilación de enlaces | aNieto2K on October 6, 2009 at 6:08 pm
  10. By Recopilación de enlaces : Blogografia on October 6, 2009 at 6:49 pm
  11. By SpotGeek.net » Preload Page on October 7, 2009 at 9:39 am
  12. By Jqueryloader – load your website in style - {rg} on October 7, 2009 at 12:41 pm
  13. By links for 2009-10-09 at ≈ Relations on October 10, 2009 at 1:22 am
  14. By QueryLoader, a full page preloader « Articles on October 15, 2009 at 1:23 am
  15. By Cargando sitio en jQuery | Kabytes on November 4, 2009 at 6:48 pm
  16. By Preloading con jQuery « Carlos Rodriguez on November 5, 2009 at 2:49 pm
  17. By jQuery Bookmarks | Блогът на Наси on November 7, 2009 at 3:18 am
  18. By 30 web designs | WebDesignExpert.Me on November 12, 2009 at 4:34 pm
  19. By My favorite jQuery resources on December 13, 2009 at 9:35 am
  20. By jQuery Animation + IE z-index bug | TKSham on February 1, 2010 at 5:05 pm