The above “solution” turned out to not be so good.
It only partly solved the issue.
What i really had to do was to edit the masterpage so that jQuery was loaded at an earlier stage.
I kept Alexanders code just the way he created it, and now i works smooth!