3

If I were to put all my files (images, stylesheets, JavaScript, icons ...) together with the index.html file direct into the project folder; using no subfolder to structure my files like images, CSS... Would that be a performance benefit?

Sure. It would be a big chaos. But it wouldn't be necessary to resolve paths like js/vendors/jquery.js

I'm not sure at all if that resolving path operations are very costly?

Kyll
  • 7,036
  • 7
  • 41
  • 64
cluster1
  • 4,968
  • 6
  • 32
  • 49
  • The benefits, if any, wouldn't pay the caos you'll get. In the SSD era, this is irrelevant. – Oscar Sep 22 '16 at 14:08
  • Yep. Sure. Had just the thought. Then realized that I have no idea about how expensive path resolving. But the question is interesting I think ... – cluster1 Sep 22 '16 at 14:16

1 Answers1

3

TL;DR Not enough to pay the price of working with such a messy project. Ans because the real benefit depends upon your system and the connection speed to the client, you have to test it, to get some numbers.


The performance improvement should be totally negligible in any modern environment. And if there is any, it is not because of the reduced SSD/HDD load.

If you discard the subfolders, your URLs will get shorter, so you save some bytes when transferring your page and also when requesting some files. That is because the shorter URLs will occur at least in the HTML (sent to the client) and the request headers (sent to the server).

The file operations on the server side and the overall handling of longer paths on the web server should not affect the performance in any measurable way. But of course even this depends upon your filesystem and hardware. If your webserver is configured correctly, it will cache the static content in the RAM (at least, while your page is frequently visited), taking SSD/HDD performance nearly completely out of the considerations.

And keep in mind, that there is a limit on files in a single folder, if your project gets very big and you use the wrong filesystem. Also, some filesystems get slower, if there are a lot of files in a single directory. More details have been discussed in this post: How many files can I put in a directory?


If you want to improve your performance easily, have a look at some task runners like Grunt. They can "build" your website before you publish it. You can condense the files by minifying the code.

You could even use Grunt to flatten your project directory structure before publishing it.

Community
  • 1
  • 1
Cellcon
  • 1,245
  • 2
  • 11
  • 27