I have some inline jquery what I want to load in the footer after the jquery is loaded.
I do not want to load the jquery in the header. And I do not want to change the inline jquery to a js file because there is also PHP in it.
But I do believe it is possible with javascript to load it in the footer.
In the header you do
var code = [];
So now you have an empty array.
And now I want to push the inline jQuery code in the array.
$(function myFunction(){
// jQuery methods...
});
So eventually you can do something like this:
code.push(myFunction);
So that I can push all the different jQuery functions and when I put the push code in the footer it will be loaded.
But this does not work for me. The console log says that "myFunction" is not defined...
function myFunction(){ // jQuery methods... }then$(myFunction);andcode.push(myFunction);function myFunction(){ // code }for (var i = 0, z = code.length; i< z; i++) code[i]();?!