I have a custom module whose front-end page is slow to load due to extensive database work (no forms, just a bunch of db queries to display some long tables). I want to add the little "loading" icon (similar to the iphone) while the page is loading, to show users the page is working. I've seen it on some of the Views administration pages, but I can't seem to find the code for it. Is the display code done with jQuery or a drupal module? How do I add the code to my module/page? Thanks in advance!

  • How are you fetching data ? Is it ajax based ? If so try this Regarding icon : this Icon is used a lot in most of the admin modules. But this is best suited for input boxes, dig around in google for loading icons.
    – GoodSp33d
    Commented Mar 1, 2013 at 6:20
  • @2-Stroker No ajax or any forms unfortunately, it's just a page bunch of db_query stuff to display data in tables. I need the icon to show while the page loads initially. Commented Mar 1, 2013 at 6:52

2 Answers 2


The loading gif is in modules/contrib/views/images/loading.gif in d7. This is a ball. The one in d6 is views/images/status-active.gif and is the clock.

Views does this in javascript:


Therefore, add an 'onclick' event on the link click or use onsubmit if using a form. If you are using ajax you should be able to use ajaxStart() and ajaxComplete() to show the block.

  • I'm not using a link or form on the page. Can you elaborate how I can use the ajax elements to display the icon until the page fully loads? Commented Mar 1, 2013 at 9:47
  • If you aren't using ajax you must be using a link to access the page? The loader needs to be shown here - I am guessing that your processing will stop any of the page being loaded, including any gif icons. Simplest is just .click() - onclick - on the pages that provide access. d6 right? You could change the architecture to load the page then trigger the processing in the background via ajax. In that case you need a module with a menu callback that does the work and some script to trigger it - $.ajax(). Use success to run .hide() or .toggle(). Also consider caching or cron to just speed it up.
    – Interlated
    Commented Mar 2, 2013 at 0:45

There is Page Throbber module which suits your requirement.

Page Throbber is a simple utility module which lets the site developer display a spinning "throbber" and a custom message to display when loading up pages which they know will be slow to load.

  • thanks this is exactly what I need! However when I installed it it gives me a bunch of errors and doesn't work when I load up the one page I designated for it to "throb"... have you tried it and does it work on your site? Commented Mar 1, 2013 at 7:05
  • There are some open issues about the errors on the module's page but you can easily get around them. Thanks for the helpful suggestion! I ended up using @Interlated answer since the AJAX approach gave me more control. Commented Mar 15, 2013 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.