I know this is an old question, but I just hit it and I think I know the answer.
I think jquery_update is causing this.
jquery_update implements a hook_theme_registry_alter that modifies $ theme_registry so that jquery_update_preprocess_page works last. This is despite what Peter sees in $ theme_registry, because the change happens after he looks at it.
jquery_update gets $ scripts from drupal_add_js (), scripts with an array and then flushes $ variables ['scripts'], which overwrites any changes made earlier.
I'm not sure what the perfect solution is. I do not think that we really should directly contact the string of scripts. I have a special one-page case, so I'm probably going to make a somewhat bad call to my code with jquery_update_preprocess_page. jquery_update for Drupal 6 is unlikely to update. This seems better than getting into the battle for the last duel.
source share