Message from JavaScript discussions

November 2020

β€” What is good practice to do that


Put each function in its own file? Put a function directly in the script tags? Put a function in the external file and call it in the html file

β€” I just wanna know how someone with experience should handle this

β€” You have no structure.. wrong, you have a structure you are trying to adapt, if you like it, ye, put everything in one huge pile🀀

Message permanent page

β€” So best practice is to put each function in a seperate file

β€” And then call the file in the page where it belongs

β€” Not a function, but the js code which that page may use

β€” Yeah exactly

β€” Love you thanks

β€” from that project

"use strict"
window.addEventListener 'load', !->
# get nodes
nodeMap =
form: document.querySelectorAll '#auth form' .0
btnSubmit: document.querySelectorAll '#auth button' .0
roleName: document.querySelectorAll '#auth h3' .0
inputs: [...(document.querySelectorAll '#auth .input')]
switch: [...(document.querySelectorAll '#auth .switch svg')]
img: [...(document.querySelectorAll '#auth img')]
# ...

Message permanent page

β€” How to protect client side routes if I got a json web token from my API

β€” Like if I go to dashboard how do I verify if the user is logged in through the rest API