I have made a lot of functions. I put these functions in a script.js file. But all these functions are loading on every page.
I have made the functions like this:
$(function () {
}):
But how can I ensure that the functions are not loading on every page?
That I can call only the function that I need?
Paul Irish has a nice way of dealing with that problem. See his article:
You can basically create an structure for each of your pages like this:
And respective page’s code will fire only with:
For that, you need to assign an
idtobodytag of each of your pages: