I’ve found something on stackoverflow that might be of some help to you for understanding what’s happening here.
If I’m not mistaken, using the <script>
tag is going to import that file globally to everything within the project. As you begin to add things globally, you could run into variable and method names conflicting.
If you’re importing, this gives you the ability to keep the scale of that js file within that component itself, reducing the possibility of anything conflicting. Typically when I am working on a project I will use import
over <script>
so I can more easily encapsulate my code.
Hopefully this better explains how this works. There are different use cases for each.