I was reading an article about Django's performances and it reminded me a performance killer we found by accident in a project at work.
We were implementing interface optimizations, like serving a single JavaScript and CSS file. Which by the way is a really nice way to improve load time of a web page.
Consider the following code:
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.ui.js" type="text/javascript"></script>
<script src="js/jquery.calendar.js" type="text/javascript"></script>
<script src="js/jquery.hanchorHandler.js" type="text/javascript"></script>
On a development POV it's really easier to maintain separated files than a single big JavaScript file. But on a optimization POV, you generate a new HTTP request for each of these script. On small scale it's not really important, but as soon as you add some load you notice de difference.
So like many others we came up with something like this:
<script src="{% app.utils.js %}
?file=jquery.js
&file=jquery.ui.js
&file=jquery.calendar.js
&jquery.hanchorHandler.js" type="text/javascript"></script>
The load time was noticeably enhanced. But at some point it got worst than before the optimization, I don't recall if it's because we used a variable like {{ js_path }} that happened to be empty, or if we just inadvertently let it empty, but at some point in the project revisions, an empty script tag was serverd:
<script src="" type="text/javascript"></script>
We learned the hard way that the browsers will perform request and download the HTML content of "/" if the src is empty. Thus generating 2 hits instead of one.
Luckily since django's runserver show HTTP requests, we spotted the problem quickly.
no comments :|