Jump to content

File Sizes

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
A programmer told me that file sizes matter extremely little and that if I want to break a file up into some smaller ones rather than one big one it would be beneficial mainly for organizational purposes.

But then the same company (Invision) has a skinning contest going on and one of the tips was to keep file sizes down for the CSS where it won't slow things down for visitors to the forums.

So which is it? Or does it somehow matter for a CSS file being loaded, but not a php file?

#2
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
Well you would think that smaller files would take less time to be downloaded. Also smaller CSS files use up less memory when stored in cache, so it is faster.

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
File size matters. Period. If you don't believe me, try downloading OpenOffice.org on a dialup connections as compared to FireFox. The issues is, are you reducing the file size by a significant enough amount for the user to care? For a website, if I don't start seeing something within a few seconds on a dialup connection, I go somewhere else.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
Yes when downloading file sizes matter, but what he said was that for php files on a site the file is not loaded at a speed related to the user's connection. I'm no expert on really anything about servers or even php, but he was saying the file is loaded by the server itself and that file size effect on loading time is negligible.

In my case it's one file slightly less than 1MB. I could break it up into maybe 5-10 files to cut the size way down, but I'm wondering if it would be worth going to that trouble. It would mean that old links in the system would need to be different so I would have to have a sort of redirecting for old links to go to their proper place and also I would maybe need to require a second file so it may be loading 2 files which possibly would be worse than loading 1 file that's larger.

Still trying to figure it out, but this is something I need to just make some decision on and worry about later. Honestly it may be a pain dividing it up and if I don't have it use 2 files at once then I would have to copy redundant functions into every file. On the other hand it would be nice to have it broken up for easier understanding of which file does what. But then again if you know which function to go to in the large file it's still easier than going through a list of files to find the right one and then still have to find the function you want in that file also.

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are a few things to consider:
1) how are files included in PHP? ColdFusion loads them only as needed, ASP loads them all as a "super" file. This can have an impact, though it is pretty minor, really.
2) Which is easier to maintain? A 1MB file would be tough to grasp. I prefer to break it up as multiple files, each representing discrete functionality.

As an example: I'm working on a site that has an index.php. It loads header.php, then menu.php, then body.php, then footer.php. body.php loads other files depending on the get/put action value. There's one for registering, logging in, etc. The idea is to have common functionality in discrete files that are used by reference. I don't like the idea of having to fix the same menu in 20 different locations.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
But if you're breaking it up into files, how does that make less cases of you having to edit the menu? You still could have the menu only once either wya.

I definitely would rather break it up and also get like functions to be one function. I just hate the idea of "doing" it. lol So I'm up in the air as to whether I will do it now or not.

Also I've never tried anything other than having one main file so it may get a little tricky (and figuring out functions in the forum software which I would need to use which I haven't had to use berfore).

My file is about 25,000 lines of code and seriously I do have a lot of like functions, but I could just as easily combine them in one file as I could if I broke it up, couldn't I?

I definitely hate having to change the same thing in 6 or 7 different areas! There are a couple cases of me having to do that currently because some functions are so similar, but at the same time I just didn't want to introduce new bugs by doing it through one function because some queries would be tricky.

Bottom line: I am definitely going to try to combine some functions into like types and I probably will break up into files too, but I'm up in the air as to when to do it. Invision's 3.0 RC 1 will eb released probably in a week or so and I would rather have my programs finished by then and maybe do this optimizing for a point release or soemthing.

But was the programmer right that differences in time when loading would be very minor? Is CSS a different situation when it comes to file sizes?

#7
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
I have built up a system to myself, similar to WingedPanther, so I put a menu in the database, with page-key, and includefile to use, this way, I still need to create small files to include for the active matter, and add a line in this table with info to the menu/or action
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
CSS is served directly to the browser.
PHP is processed at the server, and the result of the processing is served to the browser. There is a huge difference between the two scenarios. Since the PHP is processed, the file size isn't a big deal, but what it produces is.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
ok, thanks.