Reply to Re: opinions on inline server-side code?

Your name:

Reply:


Posted by cwdjrxyz on 02/23/06 23:53

John Salerno wrote:
> After doing a little reading (I'm trying to figure out how to in-line
> Python code in my HTML), it seems like a lot of purists think that
> inline code is a bad thing (sort of like inline style). I was wondering
> what you guys think of that, since you are obviously very strict about
> things like style, HTML vs XHTML, etc. (although, I've never heard any
> criticism in this group of inline PHP, for example, such as when I asked
> about it a while back).

First, inline style is not a bad thing per se, and is completely valid
according to W3C standards up to and including xhtml 1.1. One can use
an external style sheet, a style sheet in the head of the page, or a
style many places in the body as most convenient. If you use most of
the same style elements on many pages, then an external style sheet is
the way to go. If you are using most style elements only on a single
page, then a style sheet in the head is the way to go. Or the head
stylesheet can be used to override a few elements in an external style
sheet that are different for the page. This is cascading. Likewise, the
same considerations apply to a style in the body of the page at perhaps
a division or paragraph level. If, for example, you are going to use a
style only in a single paragraph or division for a single page, I find
it pointless to write the style for it in a head style sheet and then
also have to reference this at the paragraph or division where it
applies. If you for example use javascript to detect something such as
screen width after the page is downloaded, and then use this detected
width to write a style based on it using javascript, then working at
the division or paragraph method often is by far the most simple method
to go.

About the same consideration apply for deciding if you want to use an
external script, a big script on the page, or several small scripts
scattered throughout the page. You do what is most convenient.

Again about the same applies for a serverside script such as php. I
have some pages that are mostly php, some with just a bit of php, and
some with many small bits of php. In some cases you will use both php
and javascript, because some things, such as changing a color after the
page has downloaded, need javascript to do it.

In most cases the "grammar" of how you handle your css, javascript, or
php will make little difference in how fast the page loads. If you are
concerned about download time, reducing image and other media bit size
often is far more effective than fussing with code. Practical
considerations are to use a formalism that you can easily modify after
not seeing the page for a long time, and try to use external code or
head code when you can for things that get repeated often so that you
do not have to reinvent the wheel every time you write a new page much
like an old page.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация