...

View Full Version : File & structure optimisation.



Jerome
03-04-2003, 02:44 PM
Hi,

Just 5 multiple questions regarding file and structure optimisation, these questions concern download time and processor handling, which is best.

1. CSS declaration external file:

A. one line

body{color:#ffffff;border:2px solid red;etc;}

B. separate by <enter>

body{
color:#ffffff;
border:2px solid red;
etc;
}

C. other (please explane)


2. array declaration:

A. one line

B. separate by <enter>

C. other (please explane)


3. number of files you request

A. all declarations in one *.htm file

style, javascript etc

B. separate files

*.htm
*.css
*.js

C. other (please explane)


4. Does a browser send a request to the server for a *.js-file which is downloaded before and still available in the temp i-net directory?

A. Yes

B. No


5. See 4, does this count as traffic?

A. Yes

B. No

Thanks for Your effort,
Jerome

krycek
03-04-2003, 04:07 PM
Originally posted by Jerome
Hi,

Just 5 multiple questions regarding file and structure optimisation, these questions concern download time and processor handling, which is best.

1. CSS declaration external file:

A. one line

body{color:#ffffff;border:2px solid red;etc;}

B. separate by <enter>

body{
color:#ffffff;
border:2px solid red;
etc;
}

C. other (please explane)

Hmmmm, I don't see that there would be much difference in how you lay out your CSS. Arguably, if you indented the CSS that would be two characters (newline and tab) rather than one (newline or space) to be parsed, but you are never going to notice a difference! I doubt you could even measure such a difference, except maybe if your CSS file was a couple of gigs in size!


2. array declaration:

A. one line

B. separate by <enter>

C. other (please explane)

Same applies, really... although arrays tend to be tabulated more and hence there are extra characters to process. I would not expect there to be much of a difference - the same applies here as to the CSS.


3. number of files you request

A. all declarations in one *.htm file

style, javascript etc

B. separate files

*.htm
*.css
*.js

C. other (please explane)

Well, this is a two-edged sword. It will take slightly longer to get multiple files, because each one has to be opened, read, closed, etc. however you will see a lot of plus points on the side of bandwidth, because each file, once downloaded, will not have to be downloaded again until it changes. As such, although on the first visit there may be a *tiny* extra penalty for multiple files, on subsequent visits the files will not even have to be read, saving you processing as well as bandwidth.


4. Does a browser send a request to the server for a *.js-file which is downloaded before and still available in the temp i-net directory?

A. Yes

B. No

I explained some of this in my answer to 3, however I should also go on to explain that, yes, technically a request is sent, however when the file properties are checked and the file is found to be the same, the file is not read or sent. Rather, the browser can then use its own cached file.


5. See 4, does this count as traffic?

A. Yes

B. No

Yes, the request itself counts as traffic (although very minimally) but as the file is not being sent (if it is cached) you will not have the file size added onto your traffic.


Thanks for Your effort,
Jerome

No problem :) I would suggest that the best way is often the way which is most readable to you - although you may wish to "crunch" your files when they are published (removing uneccessary whitespace etc.) this is of aruable benefit unless you have a lot of whitespace. Most people do not care about the few extra bytes of bandwidth saved - although, when multiplied many times over, there is good arguement for it.

::] krycek [::

Jerome
03-04-2003, 04:43 PM
Thanks!

By the way, excellent explanation.

Jerome

krycek
03-04-2003, 10:12 PM
Heheh no worries ;) I do what I can :D

::] krycek [::



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum