I need a simple method to display a couple of numbers that are fetched externally using JS, but the method must not stop the page from rendering while waiting for the fetch to complete. The external site the numbers are being fetched from occasionally gets real slow. Sorry, my JS skills are minimal, so I am probably not using the all right terms…
In the header of my pages is a “View Cart” button that also displays the quantity of items, and the current dollar value of the cart. It looks like this:
2 items $43.89
I experimented with adding both async, and then defer, to the script’s below. In both cases the page loaded OK, but the Item Count and Dollar Value spaces on the View Cart button remained blank.
Currently, the button with the item count and dollar value is fetched and displayed with this code:
(I do need the code examples because my JS skills are minimal)