jQuery loading graphic – long pause before it shows

Hi guys

I have a very annoying situation..

Just migrated a WP site to a new dedicated server, same files, same db..

There is a page on this site that takes a long time to load due to many db queries, so I put a loading graphic immediately after the <body> tag like so (the div is styled in the css to fill the page with white and the graphic as a background:

<div class="se-pre-con"></div>
<script>
jQuery(window).load(function() {
// Animate loader off screen
jQuery(".se-pre-con").fadeOut("slow");;
});
</script>

This worked nicely on the old server, showing the loading graphic immediately, then it disappearing once the page is finally loaded.

On the new server, the page hangs for most of the loading time before showing the loading div which shows for a short moment just before the page load is complete: http://stainesfitbox.com/timetable/

Any idea why it would not display immediately now when it did on the old server?

Let me know if you need any other info on the old/new server, I have looked into this all day and cannot figure it out!

Desperately hoping you can help,

Martin

  • Martin
    • Site Builder, Child of Zeus

    Hi Michael

    Thanks for your reply.

    The page takes a long time to load (without this code) due to some heavy db queries that check the current user, their role, their booking allowance, the current time, and more in order to render a relevant timetable to the user.

    It’s because of this long load time that I want a loading graphic to display during loading. This works perfectly on the old server (identical files & db) and my local MAMP server which suggests to me it must be something config of the server.

    Thanks again

    Martin

  • Michael Bissett
    • Recruit

    Hey @totallyuk,

    You’re welcome, thanks in return for checking that out for me.

    While going into the configuration of the server would really be something a sysadmin would need to handle, if I were to jump into this, and do a quick check of things, I’d want to check to see if there’s any plugins that might not be playing nice with your new hosting.

    I’d want to disable them all via FTP (like what we mention on our Getting Support page), and then take things from there.

    One article of ours that can also be of assistance (in terms of increasing the performance) would be this one, it’s from a recent talk given at WordCamp US by our very own Aaron Edwards:

    https://premium.wpmudev.org/blog/scaling-dynamic-sites/

    Kind Regards,

    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.