A few questions today 🙂
I am using Codeigniter. I have a header view, containing my tags which contains the universal JS file loads.
It also contains the ‘layout’ of the page, links etc, sidebar, and then it opens the tag and main content . This is closed in my footer view which is loaded after and ‘content’ view.
In one particular controller, i get data using a method, pass it to a ‘content’ view, this then sets this php data to a js var (a small block of inline js), and then i include a page specific js file which uses this data. This is in my body. Is this OK?
Thanks
Modern “best practice” advice is to include your Javascript files at the end of the
<body>, if possible. That lets your content arrive and render without your Javascript execution slowing the browser down.Sometimes that’s problematic – for example, some server-side frameworks drop little bits of Javascript around page elements, and those might have dependencies on Javascript libraries.