It's a very good point, and thanks for that link! The async and defer attributes on <script> tags is one of those lingering things I still haven't played with, but it looks like you're absolutely right, the scripts should be loaded in the <head> with a <script defer ...> so they run after the <canvas> has rendered. I'll add a note to the article, and update my code again!
<script defer ...>
Comments like yours are my favorite part of dev.to, genuinely constructive criticism 😁
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.