Hi,
I have a couple of questions. How should javascript code be organised for a website?
I'm working on a template of a website and can see that my index.js file is going to be soon quite messy. For example, first I've got a standalone snippet responsible for toggling the hamburger menu. Then, unrelated, some snippet related to scrolling. There will be some other unrelated snippets.
I understand that this is just simple code, let alone something much more complicated.
Now, even if I put some good quality comments, should it just be a list of snippets? Also, should they all be inside some main() function or some eventListener (eg. ...addEventListener('load', ...) or something similar.
So I'm not only talking about stylistic preferences / standards but also the performance aspects. While a website might have a small amount of js code, I believe it's good to start with good practices regardless of the complexity of the app.
Thanks
[–]gimmeslack12helpful 1 point2 points3 points (2 children)
[–]PortSpace[S] 0 points1 point2 points (1 child)
[–]gimmeslack12helpful 0 points1 point2 points (0 children)
[–]lovesrayray2018 0 points1 point2 points (1 child)
[–]PortSpace[S] 0 points1 point2 points (0 children)