Closed jamiecoe closed 6 years ago
I've just had a chat about this with @astroash, she suggests it would be better to always include <script src="/js/main.js"></script>
on every page. However, fruit-fav.js
should be included in an additional Githubissues.
In the solution folder, the suggested position for the
<script>
tag infruits.hbs
is here:https://github.com/foundersandcoders/express-handlebars-workshop/blob/7252e3c49868c30e3dc4fa5af943cb8ca816e0fe/solution/src/views/fruits.hbs#L29
I would suggest that this is confusing, as the script tag then gets rendered inside the
<main>
tag.Best practice would be for the
<script>
tag to go in the<head>
or at the bottom of the<body>
. Also the fruits page has bothmain.js
andfruit-fav.js
included in it, which may or may not be correct?My solution to this would be to make a partial for the
<script>
tag, and pass in thesrc
value when you render the template. eg: