Shortest way of firing a function on ready with jquery -


this such trivial question, have function...

galleryajax(); 

and fire on doc ready. writing this...

jquery(document).ready(function($) {    galleryajax(); }); 

it seems little long hand , wondering if there shorted way of writing this.

thanks
josh

you can directly pass function jquery:

$(galleryajax); 

from .ready documentation:

all 3 of following syntaxes equivalent:

$(document).ready(handler) $().ready(handler) (this not recommended) $(handler) 

of course if want execute more functions on dom ready, makes sense pass anonymous function:

$(function() {     galleryajax();     // other functions called here }); 

Comments