I always place all my packages immediately following the document class, followed by setting information (\hypersetup for example) and customization to my documents (header and footer customization for example), and macros for use in the document.
Is there any case were you would want to load code before you load a package?
This answers points out that for clarity you might want to have setting information immediately following the package, to reduce the amount of documentation you have to do (For example, I should move \hypersetup to be right after \usepackage{hyperref}, but before any packages that follow it, achemso or cleverref or whatever)
I thought all packages had to be loaded first, but it seems that in some cases you need code before them, for example you need to set \author, \title, and \date before you load the titling package.
So, are there cases where it is technically better (or required) to write some code before loading a package? By technically better I mean, makes a difference to the compiler, not just someone reading the code later.


\bibhangshould be executed with\AtBeginDocumentto remove that dependency on code order. – Martin Schröder Sep 23 '12 at 13:07