开发者

Delay Loading in jQuery

开发者 https://www.devze.com 2023-03-21 07:19 出处:网络
I have a page that uses jQuery and a little bit of jQuery UI and displays a wizard of a 7 page long questionnaire. Each section of the wizard is essentially a div that is later displayed when the user

I have a page that uses jQuery and a little bit of jQuery UI and displays a wizard of a 7 page long questionnaire. Each section of the wizard is essentially a div that is later displayed when the user goes on the respective page.

I feel like the load time for the site is slow, and was thin开发者_如何学编程king if its an option to delay the loading of the 6 pages that follow the first page, just because its at least a few seconds before the user goes on to the next page. I am not using jQuery tabs, but a custom wizard plugin.

Thanks!


setTimeout(function(){
  $('#secondTab').ajax('your-url-for-the-second-tab');
},2000);


If you want to delay the loading of subsequent divs, then you will have to remove them from the main page and then dynamically load as needed them with ajax calls. This will require changes on both client (to write the ajax call to load the subsequent divs and display them as needed) and on server (to remove them from the main page and put them in a place where you can retrieve them with ajax calls).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号