Hello. I have a question about saving bandwidth that maybe someone will know about:
Can/should you use javascript files to save bandwidth?
My example:
I have 50 seperate php pages that have a left-side navigation.
The left-side navigation is the same for every page.
I don't want to use frames to save the bandwidth.
I don't want to have to get the code from my server on every seperate page request since it will be the same for every page.
How about this?:
Make a javascript file called leftnav.js and have it write the left side navigation, and then call that javascript file on all the php pages. This way, instead of having to send the code to be echoed for each new page from the server, it would get the javascript file from the visitor's cache, and then display the navigation.
If the left side navigation was 50kb, then it would download the 50kb javascript page once, and then load it from the cache, saving 50kb of bandwidth for each new page they visit that has to load that left-side navigation. Maybe even make two files called layouttop.js and layoutbottom.js that include the whole page except for the unique content to that page?
Is this a reasonable idea? I'm not sure, but it sounds good. I have not seen anything like this documented on the internet yet.
Anyone have some ideas? Or actually know if this is a good idea?
Thanks so much any help, and hope this may help others as well.
- The Maxx
**EDITED BELOW BECAUSE OF STUPIDITY**
Okay, I thought about it, and the javascript thing might work good for html pages instead of using frames or iframes (don't know what else would do it for html files), but for php files, how about using the include() function, or better yet, the require() function? Have the page like this?:
<html><head><title>PAGE NAME HERE</title></head><body>
<?php
CONNECTION STUFF HERE
require ('left-nav-etc.txt');
require ('top-nav-etc.txt');
echo "PUT THE UNIQUE PAGE CONTENT HERE";
require ('bottom-nav-etc.txt');
?>
</body></html>
How does this sound.....? Thanks again! 🙂
P.S. - sorry to make it so much reading 🙁
- The Maxx