Tweak api.js ifle

 - Use an IIFE
 - Use a DOMContentLoaded listener to append css