Think about it, in the 'full stack' of browser -> client -> interweb -> web server -> app server -> db server the little bit of code that you wrote is minuscule compared to what you didn't write. Tune up your TCP stack, tune your webserver, add cache headers, add indexes, etc. Most apps can drastically increase their performance with out even changing a single line of code. And when you're tuning up your code, look for single lines of code to change.
Definite protip in there on debugging with wireshark.
We had a client once that we could only login to their IMAP server but not download mail. A little bit of digging with wireshark and we figured out that he had some old POS router that couldn't handle window scaling. Solution? Turn off window scaling on one of the servers.