treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Javascript! Grayscale! Onload! What?

  • Hi everyone,

    Long-time lurker, first-time poster. I'm a designer who knows a little HTML and CSS but absolutely no JS. I threw together a site last week as a simple portfolio for some of my work. I don't have much on there yet, but the link is as follows: www.legalcolors.co/works

    THE PROBLEM, THOUGH, IS: the page loads before the grayscale-to-color javascript loads, so it displays in full color, then in grayscale, and I think it looks unprofessional. Like I said, I usually don't post, but I'm throwing my hands up on this one. Any thoughts?

  • Hi @ashenrose

    I'm on my phone so it's hard to tell really but it sounds like the function is loading when the document is ready i.e. when all the elements on the page load - then do this function.

    To overcome this you could change the script/function to run when the window is loaded like (window).onload rather than (document).ready. I think that will sort it, but I could be wrong...