Hi there,
I am working on a medium size web site that has plenty of custom JavaScript written for it.
At present all the script is stored in seperate JS files for each area of functionality. These are then minified and combined into a single, large JS file during our build process.
For each page, the relevant JavaScript is usually executed based on the presence of an element with a particular class on the page. For example:
$(document).ready(function()
{
var foo = $("div.dostufftome")
if(foo)
{
// dostuff
}
}
I'm concerned that this approach seems a little fragile, and also potentially quite slow.
The only other alternative I can see is to put the 'activation' code inline in the HTML in a CData section, with the bulk of the code in the attached JS file.
Grateful for any advice.