Include Files

Nathan C

New Member
Hi All,

I am looking at streamlining the way I build websites.

I want to be able to include my navigation code in a separate HTML file and then pull it in to all the pages on the website. Just so if I want to update the nav I don't have to search and replace every page on the site I can just do it from one file.
Same goes for the website footer.

I have looked at a couple of different ways, one way was Javascript function that pulled in a HTML file something like this:

script>
$(function(){
$("#slider").load("/includes/home/slider.html");
});
</script>

This worked fine but I cant help but think that it has negative effects on SEO, and load speeds seemed to also take a hit.

I think PHP includes might be the best way to do it without affecting SEO/load speeds much.

Has anyone had any experience with something similar/got any suggestions?

Thanks in advance,
 
Honestly, from a personal perspective, that to me isn't streamlining the site for the client or person accessing the site.

You have an additional script and an additional webpage to pull in versus just having a few lines of code.... what happens if javascript is disabled.

PHP can pull in outside sources but again it's basically adding load for what is a very simple and expected thing to find on a webpage, if your menu is more than a few kb's then you're doing something wrong imo.
 
PHP includes are the best way to do this. But for a small static site I wouldn’t bother.
 
Back
Top