Help squashing bug

Hi,

On my JavaScript calculator ( https://github.com/zelite/JavaScript-Calculator ), i noticed that when the page is loaded and I try to make the first calculation, e.g: 1 + 2, there is a small freeze in between the + and the 2. The number 2 takes a bit longer to show up. This only happens on the first calculation. If I press AC the calculator is reset to the starting state but the small freeze does not happen again. If I reload the page then the freeze will happen once more at the first calculation.

Do you also see the same issue on your side? Any suggestion on how i can figure out what’s going on? Or maybe someone has seen this behavior before and knows the likely cause for it?

Thanks!

Link to some live example.

You can use GitHub pages to serve a live version of your working GitHub repos:

Oh sorry, it was already live. Forgot to post the right link: https://zelite.github.io/JavaScript-Calculator/

I noticed the problem just shows up on mobile browsers (tested Opera and Chrome for Android)

I think I figured it out.

I am using math.js to deal with the calculation. And it seems that only loads the library on the first calculation (some sort of lazy loading must be going on).

So I just make a calculation in the background before the calculator is initialized and from there everything seems to go smoothly.

Well spotted…Clever!

I totally would have ignored that and given up - it’s only a split second delay on my machine. Kudos for sticking with it.