Loading Pages with jQuery

In my quest for redneck perfection, I try to stay in a constant state of improvement, working and refining on my craft. One of my goals this year is to get better at coding in JavaScript. I started using JavaScript when Alta Vista was the top search engine and jumped on the JQuery train in 2006. But it’s never been my strongest tool, and I want to get better. I just started reading and doing the exercises for A Smarter Way to Learn JavaScript (so far, so good). I’m lucky enough to be in a position to expand my skills, and I get some JavaScript work from time to time, and usually, they aren’t a big deal, but this time I really struggled to get a dynamic image to load, if I had hair, I was ready to pull it out.

I tried wrapping my script in every type of “$(document).ready(function()” I could think of even trying “(“#id-thats-loaded”).ready(function()”. Finally I learned that “(document).ready(function()” only fires when HTML is loaded and DOM is ready.

And using a “$(window).load(function()” fires when the complete page is fully loaded. After I wrapped the script in the “$(window).load(function(),” the page loaded correctly.