The thing is, includes are not something you can do with plain HTML. You have to use a script or tool of some sort to handle it. The original include was the SSI or server side includes. But now you can create includes with languages like PHP and ASP, JavaScript and even frames. You can also use tools like Dreamweaver library items to act as includes offline.


It all depends on the site you’re building. It won’t matter much for tiny sites, but when/if your content/interface starts growing in quantity it would be smart to use simple includes, some template system or invest in a CMS.
I wouldn’t use JS for this task, period.
If no other technologies are available (or installable) on the server I suppose frames could also do (if done well) even though I’m not sure exactly how good the frame support currently is (I’m referring to screen readers and handhelds). I believe Flash is also an alternative if we’re not talking about HTML content.
I personally go with PHP.
Like many poles only being able to select one from many is misleading. We use a number of the ‘include’ techniques you mention depending on the cost benefit analysis (SSI is easier than PHP and Javascript but there are reasons to go with each techniques). For example, unless an organization is set up with internal servers then checking out SSI implementations requires uploading to a server to test – wastes time. You get the gist of this message I am sure.
I have used PHP includes for some time. Invauable for footers and headers, especially when changing the annual date in the footer at the start of the new year, alter one file, upload and repeated across the entire site!
Using PHP is very simple as well, one line of code, create your include file and thats it!
I prefer to use PHP in my html pages. For a single page you would not have to use includes, but when you have to deal with 3 or more pages, it is convenient to use PHP includes. Typically I have an include for the top part of the page, one for the menu bar at the left side, and occasionally one for the footer as well (if I’m really enthousiastic
). Even while the pages are still being developed, it is worthwhile (I repeatedly change the layout while I’m working on the pages, so that is a good reason to use one include rather than change all pages all the time…). Besides, what I really like about PHP for menu bars is the possibility to change the appearance merely by changing the name of the page.
I think PHP is the best choice, since a simple include (which may consist of another PHP code section or another HTML code section). It is very useful, especially if you have menus, a simple do the right job!
Trying to do the Include via JavaScript is playing Russian Roulette with 5 bullets in the chamber. You can not expect it to always work due to paranoid users who turn off JS support for various “protection” related reasons. Using a NOSCRIPT tag to point out that the site needs JS to render is counter productive as well as ticking the user off by pointing out their intentional crippling of the browser.
I have used Apache Server Side Includes from almost the beginning of learning web design. I have found them invaluable. Anyone who has ever used them knows the savings in time, code and errors especially in the design stage of a site.
They are fairly easy to learn to use if one wants just to create a web site template. I have also used Javascript and PHP includes though not to the same extent as Apache includes and always to return to Apache.
They are well worth the time to learn if one is planning on expanding a web site or doing much revising. I have put together a web site of some of my favorite includes if anyone is interested. The goal is to share what I have learned but it is still in process.
SSI has been a true blessing for me. It has enabled me to update my navigation through out my entire website. At first when I only had 10 to 15 pages, updating my site was easy, but when my site grew in pages it was necessary for me to start using SSI. You have to check first if your web hosting provider supports this, if they don’t, look for another web host and transfer.