Showing a throbber during html page load and rende

2019-07-13 16:41发布

I have a page that renders slowly. The trip across the net is quick. The initial load of the page is quick. You can actually see (if your machine is slow enough), the initial layout of the html components. Then some javascript stuff runs, making some of those components all ajaxy. Then finally the css gets applied.

I can't do anything about the javascript that's slowing everything to a crawl. So I need a throbber to tell the user to hold up, the browser is working. Is there any way to trap the browser is done rendering event? Is there even such an event? Is there another way to do this?

3条回答
够拽才男人
3楼-- · 2019-07-13 17:00

Check to see when the DOM is ready before calling all your Ajax stuff.

using Prototype:

document.observe("dom:loaded", function() {
  //your code
});

using jQuery:

$(document).ready(function() {
      //your code
});
查看更多
smile是对你的礼貌
4楼-- · 2019-07-13 17:07

Show the throbber before the code is run and hide it after.

Using JQuery:

$("#throbber").show();
/* Your AJAX calls */
$("#throbber").hide();
查看更多
登录 后发表回答