After loading a certain number of javascript/css files, the files are taking too long to load

apache-2.2csshtmljavascript

I have a problem where on page load (after a certain number of .js or .css files) the files are taking way too long to load. At first I thought that the issue must be inside the .js files, but later I realised that the content is irrelevant, I tried deleting the content of the .js files that took too long to load and the issue was still there.
I also realised that if I change around the order in which the files are loaded then the one(s) I leave for last are always the one(s) that take very long to load (this load time differs from PC to PC, on mine it's 5-6 seconds, on another one it's 19-20).
I'm currently using Apache 2.4 for development and I suspect that the issue must be in the settings somewhere.

You can see the issue here:

image

Any help would be appreciated.

Best Answer

The situation is rather strange. My suggestion is to profile your application client side and try to understand what is going on.

Generally the problem could depend on:

  1. A locally cached content that is very slow to be read, this should not depend on a particular file corruption since the files being slow depend on the sequence you put in the JS referencing.

  2. A rendering problem on the client (though this should not change on the sequence of the referenced items)

  3. A possible problem of parallel transfers on your apache server. This could imply that you have a truckload of files to be taken with different GET operations and Apache cannot serve all of them in parallel. Therefore a serialization could occur with the effects you are experiencing.

  4. Different ways to get the same files, possibly opening another worker on apache (i.e. main page through direct IP to Apache, JS over proxy pointing to the same Apache. And Apache being configured in a single worker scenario (I don't enough information to judge it)

  5. A damn antivirus acting locally which triggers on the browsers loading operations

My advice is to do the following:

  1. Install a profiling tool (my preferred one is to use Firebug)
  2. Profile the application in NET panel
  3. Load the page and see how the items are loaded
  4. Try to check the logs in Apache. For this particular issue, if you are working on a development server, try to increase the logging level to debug. "LogLevel Debug"

At the end of the profiling you will notice which is the cause of serialization of the process.

Related Topic