Adding script to custom head doesn't work

I tried to put a script to init variable in the custom head, but it doesn’t render on the page, only the external scripts are shown.

e.g.

<script type="text/javascript">
var _v = _v || [];

_v = 9;
</script>
...
[external scripts that use this variable]

If it is compiled automatically by Discourse, it ruins the execution order of other scripts that follows it and need to use that variable. If so, is there an option to exclude it from compiling to another file and have it inline as it is? By that, I mean both the inline and external script appearing in the page as I wrote them.

I’m dealing with a similar issue now. I think what needs to happen is that you need to get your code into an initializer and to do that it will need to be in a file rather than in the header.