How to stop webpage loading until all jQuery download functions are complete?

I am working on my first large website and have some problems regarding how to scale it. I thought using jQuery to build each page (over 200 pages). Most of the elements that appear on each page are created in a separate html file and then loaded using jQuery.load. The advantage is that I only need to make changes to the file once and it will change on every page (is there a better way?). If this is an acceptable way, how do I first stop loading standard html / css? Currently, the page loads the background and several elements that are unique to each page, and then loads the other elements of the html file afterwards, which makes it unprofessional and annoying.

Thank!

+3
source share
1 answer

is there a better way?

Yes. You can force your server to do this, although this will depend on your language / framework: PHP, Python Django, etc.

(If you just work through a web server, without any programming on the server, then I suppose something like .load()is your only option.)

BTW, to solve this problem, content management systems such as Drupal are created without the need to write code.


How do I first stop loading standard html / css?

If you want to stop something from showing until you're ready, add the body tag

<body style="display:none">

And then when you are ready,

$('body').show();
+3
source

All Articles