Calling an API after a function?

I've been trying to understand (after spending the afternoon trying to find the answer), I have the following code:

<script>
function wtv(something){
 console.log(something);
};
</script>
<script src="https://api.com/api?callback=wtv"></script>

When I place the api script before the function script, I get a Uncaught ReferenceError: wtv is not defined

Why is that?