I would suggest adding class no-js
to your html to nest your CSS selectors under it like:
.loading {
display: none;
}
.no-js .loading {
display: block;
//....
}
and when you finish loading your credit code remove it:
$('html').removeClass('no-js');
This will hide your loading spinner as there's no no-js
class in html it means you already loaded your credit code