This works for running the same code on both ready and resize:
$(document).ready(function() { $(window).resize(function() { // Stuff in here h
Bind it both the load and resize event as below:
$(window).on('load resize', function () { // your code });
Much simpler - hope this helps.