Method 1:
$(function(){
initPublish();
});
Explanation: initPublish() is the JS function you want to run; this code is placed at the bottom of the page.
Method 2:
$(document ).ready(function () {
// add your code here
initPublish();
$(.a).click( function (){
// add your code here
});
});
Method 3:
window.onload = function (){
// add your code here
}