How do I get rid of my inclusion race-condition on wp_enqueue_script

If you run wp_enqueue_script() inside a shortcode, which is essentially what you’re doing by calling enqueueAllMyStuff(), the script is going to be queued up to be loaded in the footer. So if your shortcode runs a script as soon as it’s printed, the JavaScript file that it depends on won’t be available yet, and will cause this error.

The simplest solution is to update your script to wait for the document to have loaded. With jQuery you’d use jQuery( document ).ready(), but in vanilla JS you can use:

<script>
    window.addEventListener( 'DOMContentLoaded', function() {
        do_cool_stuff();
    } );
</script>