Load embedded checkouts more smoothly using a fade-in loader!
Loading short pages that contain an inline checkout can sometimes take a second to load up depending on page speed. This can be smoothed by adding a full-page loader that hides the contents of the page until the page AND Spiffy are loaded.
Add this code to your page AFTER your Spiffy.js code:
The above code will hide the loader after Spiffy is done loading your checkout, though you can adjust when this triggers by changing the event it triggers on.
You can use any event supported by Spiffy.js for adjusting when the loader hides. You can also scope this event listener to a specific checkout (see full event documentation)
Load right when the checkout is loaded (but may still be painting):
spiffy.on('form:ready', hideLoader)
Load right when Spiffy.js is mounted (may be prior to checkouts being loaded):