Feedback - Random Quote Machine - Slow Loading?

Feedback - Random Quote Machine - Slow Loading?
0

#1

Hi all,

I’ve just finished the random quote machine project (yay!). I’d appreciate any feedback you have on my code.

Specifically I noticed there’s a little bit of a lag on the page before it loads the first quote. Clicking for the new quote goes fast, but when I first load the page the box is blank for a second or two.

I can’t figure out why. Any ideas?

https://codepen.io/nabramow/pen/EbaaZR

Thank you!

Nicole


#2

One thing that might help is to only call the getJSON one time before the page loads (outside the .ready function) and make use of the large array in your getQuote function and randomly select a quote from the 2 dimensional array each time the Get Quote button is clicked. This may only slightly help the first quote, but will greatly speed up an other quotes, because you will have to wait for a response back from the API after the button is clicked. Of course you will have to modify your existing code to handle this change suggestion.