Make jquery.load before loading HTML

I have boot navbar in file navbar.htmland I load it into my HTML page usingJquery.load()

I have this at the bottom of my HTML page:

<script  type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script> 
$(function(){
   $("#navbar-partial").load("navbar.html"); 
});
</script>

and <div id="navbar-partial></div>are located on the HTML page.

After partially displaying in the navigation bar, I have the main content div with everything else on the page. The main content is loaded first, and then the navbar makes it look “sticky”. If I put the navigator code in every file that it downloads first and never seems to change, it loads quickly, but I want to extract the code into one file, so I don't need to edit it everywhere.

Any ideas on making the navigation part load first or faster? I moved the script tags to the head, and that didn't help either.

thank

+2
2

$(function(){ , DOM .

, , :

<div id="navbar-partial></div>
<script> 
    $("#navbar-partial").load("navbar.html"); 
</script> 

- , :)

, , , HTML , .

+3

, .

, "dom ready".

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>$("#navbar-partial").load("navbar.html");</script>

# navbar-partial HTML, .

, - AFAIK. , , -

<!--#include virtual="navbar.html" -->

: http://www.ssi.su/#include

+1

All Articles