I am using AJAX to load pages, and am wondering what is the most efficient way to initialize JS that is stored in an external sheet on every page load. I have just made a bunch of functions and one "container" function that I call whenever load()
is finished inserting content.
Basically:
function initContainer() {
functionOne();
functonTwo();
functionThree();
...
...
...
}
I have a quite complex site/app, and there is a lot of functions. It seems very inefficient and bad, but I am not having any problems per se. Am just wondering what I can do to make this better.
I am using smoothState.js for some of the page loads and it only has one onAfter
hook, therefore I must have a function like initContainer()
because I dont't really know which page is gonna get loaded and which functions I am going to use.
Thank you