Forum Moderators: open
and have found that by closing all the gaps in my code, (except where scripting requires new lines!!!) i have cut down file sizes considerable and can live with the downside which is that when editing it becomes harder to see whats what.
but are there any other drawbacks from a spider point of view (or any other for that matter)
1. All JavaScript
2. All CSS
That in itself will shrink your html considerably. Removing all spaces, tabs, etc. is another step and yes, if you are not used to the format, it can be difficult to locate things. If I ever run into that issue, I insert comments and a white space above the comment tag so when I scan the html I can see where the section breaks are.
I always tell my clients that if you view the source code of a web page and your browser tells you that the file is too big for Note Pad and requires Word Pad to open it, then it is too big!
P.S. I've seen no drawbacks in performing the above steps. If there are any, the advantages far outweigh the disadvantages.
Things you do to save bandwidth will usually make your pages faster too, which improves your visitor's experience.
Something else I did was to convert some recurring elements to external .js files, to take advantage of client-side caching. Example: I have a search box on every page and a large drop-down menu. I moved both of those to external .js files. The first page that gets visited will not save any bandwidth that way, but as visitors move around the site those elements are already in the browser cache so subsequent pages will be leaner and faster. Also (still learning here) I'm using CSS to eliminate tons of font tags etc. and using an external CSS file.
Optimize all graphics (I find the GIFbot at NetMechanic to be helpful here), and be cautious about using a graphic if text can do the same job (for instance, in menus).
The reason this came up is because I made a suggestion to someone to place all their css and js in external files. They replied stating that the hosting server loaded the pages slower when they had external files. Their host told them it was because of the server speed and the number of sites that server had on it.
I haven't had to worry about that issue yet, don't think that I ever really will unless I change hosts. We have about 220 sites on that server, not enough to blink an eye at!
That is what I like about this forum, what is obvious for one is a discovery for one other. I keep on learning everyday. Thanks for sharing it pageoneresults and buckworks!
SSI includes have to be processed new for every page and yes they will slow down the host server a bit.
buckworks, my includes contain images and such. Are you saying that those images are reloaded each time a page is visited that uses that include? Or is it just the calling of the file itself? My understanding is that each time an image is loaded into users cache, that it won't load again unless they clear history.
been using external css and js for a while which is definately a great help.
and they are surely cached so when you use the same styles over and over again only one call is required.
The next thing would be to rid yourself of additional tables that are not required, if you are using them. Empty tags, broken tags, etc. are all candidates for compressing your html.
Other possibilities of reducing bandwidth are using:
1) site-wide graphics
2) smaller variable/form names
3) server side file compression
4) hand coded html/javascript
I also put all my js and css in external files, I find it works great. I use Dreamweaver most of the time, take the javascript it creates and make a seperate file which all of my html pages call (if they need the js of course!). I have also found that sometimes the server downloads the external files last or slowest or something, and for about half a second my page doesn't have a background or something, but generally it works really well. Definetely recommend doing it.
But the <font> tag has been deprecated. Although it's not dead yet, it won't be around indefinitely. Since CSS was created in part to get font tags out of the markup, it's interesting to me that browsers even execute a class on a font.
<script type="text/javascript" language="JavaScript" src="javascript.js"></script>
So what would be a good rule of thumb for external JS files calls? Put all those Netcape bug fix, sniffers and rollover scripts in the same file usually makes a 4 k file. Is it worth it?
But if I only have rollovers on certain pages, then I put the rollover script in it's own file (eg. rollover.js) and only call it on the pages where it's necessary.
You can download this (free) from [serpik.com ].
HTH
BlobFisk
Thing is though... if you write your HTML code and scripts by hand you'll find that stripping tabs, spaces and line breaks will only save you a few % points. It's almost pointless. If your HTML is bloated it's because you're using a WYSIWYG editor.
About external js and CSS... to settle the debate :-) they save both bandwidth and time.
No js and CSS do not slow down the server. Only SSI can do that.
SSI is not cached. It is exactly as if the code were included directly in the HTML page.
External files are checked every page load, not just the first one. No one mentioned that one yet. The bandwidth savings happens because every time after the first it's only the fraction of a second it takes to inform the broswer that the file hasn't changed.
Another small savings (if you're hosted on a good server and have your external calls before any image preloading) happens because, even on a dial up connection, the first second of straight text will usually transmit at 8-20 K/second (sometimes more) before packet loss starts to kick in.