Put <script> to the end of HTML is old approach (to be sure that JS will be executed only when all HTML is loaded). With it JS file will be loaded a little later.
Modern approach is just add defer attribute which ask browser to run script only when HTML will be loaded.
Thanks! Yep, it could be a great idea, but we always need to look at exact case. In case with the React app I think it doesn't make sense. Besides it is just the default for the Vite boilerplate.
Put
<script>
to the end of HTML is old approach (to be sure that JS will be executed only when all HTML is loaded). With it JS file will be loaded a little later.Modern approach is just add
defer
attribute which ask browser to run script only when HTML will be loaded.