foundersandcoders / express-handlebars-workshop

7 stars 10 forks source link

Script tag position needs changing? #17

Closed jamiecoe closed 6 years ago

jamiecoe commented 6 years ago

In the solution folder, the suggested position for the <script> tag in fruits.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.

screen shot 2018-02-09 at 13 51 29

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 both main.js and fruit-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 the src value when you render the template. eg:

res.render('home', {
    activePage: { home: true },
    script: '/js/main.js' 
});
jamiecoe commented 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.

  • Githubissues is a development platform for aggregating issues.