I use a lot of javascript on my site. It works and has passed crossbrowser testing, but the thing is the javascript files are being included within Joomla articles. I’ve read that this is the wrong way to go about it, but I don’t know why and am not sure of a better way to do it (I believe one reason had to do with the javascript not being included in the head of the webpage).
IMPORTANT I’ve considered including the javascript in the template, but each Joomla article can be vastly different. While I try to be consistent with articles in similar categories this isn’t always possible. If I were to include the javascript into the template I would need to create a different template for each category type and then I’d still need to include the odd script into a few articles.
Perhaps I should include the javascript via custom html modules? I’m not really sure what benefit this would provide over the current method.
QUESTIONS
- Should javascript not be included via joomla articles? If yes, why?
- How would you include javascript in this situation? Remember that each article can use vastly different js.
EDIT1
I'm particularly interested in how people would recommend I add the javascript to Joomla in my situation.
media
folder and including it from there? Maybe building everything around JavaScript objects and reducing the the code duplication (where possible). If you ever need to update something, you just need to edit one fine, not tons of articles. My 2c.