Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using jQuery Plugins Using a jQuery Carousel The Carousel Challenge Solution

Philip Kroupoderov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Philip Kroupoderov
Front End Web Development Techdegree Graduate 21,641 Points

Weird big flicker of photo when reloading the page

After solving the challenge, whenever I reload the page there is a big flicker of one of the photos. You can see it in the video as well at 03:35. I know it has something to do with the plugin's code but still, anyone knows what can be done to remove that flicker??

1 Answer

Steven Parker
Steven Parker
231,248 Points

That happens because the slide images are loaded to the page first, and then jQuery and slick code is loaded and run to create the carousel. The way to avoid the "flash" is to not display the images until after the slick function is called:

styles.css
.slides {
  width: 100%;
  height: 100%;
  margin: 0 auto 40px;
  display: none;  /* add this line to hide the slides initially */
}
index.html
      <script>
        $(".slides").slick({
          dots: true,
          slidesToShow: 4,
          slidesToScroll: 4
        });
        $(".slides").show();  // add this line to reveal the slides after calling slick
      </script>