 WEGCash.comOur free trials are converting insane and we pay top dollar. Check us out for more info.
 Hosts4Porn.comThe Adult web hosting resource. Articles and reviews on the various adult hosting providers.
 braincash.com$35 Per Signup. Exlusive Content featuring such stars as Peter North, Lexington Steele to name a few.
 Exclusive Plugins15+ niche plugins of great reality content! Pricing starts at $99 per month! All Plugins Included!
 PythonHi-Def content that will blow your surfers away! 1000+ Hosted Galleries!
|
|
Keeping Your Code Tidy
(Article Contributed By Dino - Posted on August 05th, 2008)
If you have any comments on this article (or any other that appears on PornResource.com), and idea for one you'd like to see written you can email them here. You can also email us with any interesting news items you find on the web or if you'd like some help in our regular Monday Help-a-Pimp section. Got a question? Send it in! We also accept article submissions (subject to editorial changes) for publication.
The newer breed of WYSIWYG editors are a lot better than their older counterparts from a few years ago, but the code they produce still has a lot of room for improvement. For the first part of today’s article, we’re going to look at a few simple optimization techniques you can use to strip down the file size of your finished pages.
Shaving a few bytes here and there doesn’t seem like much, but it can add up over time and also help eliminate cross-compatibility bugs that often crop up with editor-generated code.
Line Feeds and CR's; these two things can account for a lot of wasted space in a raw HTML file. While we as humans prefer to work with neat, ordered displays of text and code space out onto lines with returns and such, the browsers themselves ignore all the carriage returns within a file (unless specified within a block of text). Some editors out there like to produce code with a lot of blank lines where they’re not really needed and so removing these frees up a little space.
It’s not going to be huge, but the reduction in file size over a few million page views will certainly be noticeable.
Tables are probably the worst thing for some editors and the biggest problem when it comes to cross-compatibility with pages and sites between Firefox and IE. IE is extremely fussy about open and closed TD, TR and TABLE tags and will trip up with even the slightest error. Firefox on the other hand is a lot more forgiving and will correctly display a page even if some of the tables within it are slightly miscoded.
One trick I have used for a long time is to stay away from putting TD open and close tags on separate lines, instead encapsulating the entire tag and table row on the same line of code.
Keeping it neat and tidy like this also cuts down on the extra carriage returns as I mentioned before. Of course if you have multiple cells within a row you’re going to need to modify this a little, but it’s not too difficult to figure out how to do it.
I am really guilty of overusing the tab key and it comes from my COBOL and C programming background. In both languages, tabs are used to position code for easier reading although COBOL actually requires code to be on certain columns on some of the older compilers. Tabbing everything out in C and C++ is a more or less accepted standard coding practice now and helps with neatness and readability. Sadly, when it comes to parsing all those tab characters are taking up space and can sometimes throw off browsers.
It doesn’t happen often but I have seen pages display incorrectly because of tabs in the wrong place or simply because of their use within a table. Tabbed code looks great to a human reader but it’s more trouble than it’s worth for most applications. If you must, tab out everything while you’re developing and then remove all the tabs for the live version just to be on the safe side.
Every good programmer comments their code and HTML is no exception. The problem is that these comment lines within a standard, fixed HTML page are pretty useless unless you’re planning on letting other people edit your code. Use them by all means but keep them as short as possible and only use them when you absolutely have to.
CSS
While it’s easier to put your style sheets within the actual HTML page itself, if you’re using the same styles across multiple pages or sites it’s a lot more efficient to have them outside in their own file, and call them into the page using an external CSS declaration. Rather than duplicate redundant data across every page, you specify it outside of the text once and use it when you need it.
There are two schools of thought on meta tags – some say that they are now pretty much useless and should be discarded. Others say that they are coming back into common use and that some engines are using them to aid in ranking or classification of the current page. Personally, I use the very bare minimum (description, title and maybe a few keywords if I think I have the space) and that’s about it. Most WYSIWYG editors throw in all sorts of crap in the HEAD tags, so check to make sure.
Till tomorrow, pimps!
Go Back to The Porn Resource
|
|