Elegantly Run a Function on Window Load or Window Resize

By Forrest Smith - Drempd.com

Pretty straightforward, but I wanted to run a function on the window load event, or if the page was resized (like resizing page elements). I was originally doing this in two lines of code (one for loading, one for resizing), but wanted something more elegant:

$(window).on('load resize',functionToRun);