What is the best way to structure your js for performance speed as well as page load speed, less strain on the browser.
var myFunc = function(){/*do stuff*/}
or
function myFunc(){/*do stuff*/}
What is the best way to structure your js for performance speed as well as page load speed, less strain on the browser.
var myFunc = function(){/*do stuff*/}
or
function myFunc(){/*do stuff*/}
There is no difference in performance between these two methods.
var myFunc = function(){/*do stuff*/}
or
function myFunc(){/*do stuff*/}
However the first function is created only when the line is executed. But the second function is available even when the script starts to execute.
It is important to understand Javascript Hoisting to explain this behavior.
Here is another useful article on this.