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:

function wtv(something){
<script src=""></script>

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

Why is that?