slight mistake requestIdleCallback(appendPosts(newArticlesHTML), { timeout: 1500 }); needs to be changed to requestIdleCallback(function(){ appendPosts(newArticlesHTML); }, { timeout: 1500 }); otherwise both sides of the if and else execute in the exact same way.
Okay! thanks for the heads up. Interestingly I basically did that in the actual implementation, but I thought I was prettying things up before posting this here. I sometimes forget how JavaScript works in this way until I hit the error and fix. π
I'll update the code in the piece.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
slight mistake
requestIdleCallback(appendPosts(newArticlesHTML), { timeout: 1500 });
needs to be changed torequestIdleCallback(function(){ appendPosts(newArticlesHTML); }, { timeout: 1500 });
otherwise both sides of the if and else execute in the exact same way.Okay! thanks for the heads up. Interestingly I basically did that in the actual implementation, but I thought I was prettying things up before posting this here. I sometimes forget how JavaScript works in this way until I hit the error and fix. π
I'll update the code in the piece.