const hasLoaded = { } ; const fetchPromiseStylesheet = ( url ) => { return new Promise ( ( resolve ) => { if ( hasLoaded [ url ] ) { return resolve ( undefined ) ; } const link = document . createElement ( 'link' ) ; link . type = 'text/css' ; link . rel = 'stylesheet' ; link . onload = ( ) => { hasLoaded [ url ] = true ; window . requestAnimationFrame ( ( ) => { resolve ( undefined ) ; } ) ; } ; link . href = url ; const headScript = document . querySelector ( 'script' ) ; headScript ?. parentNode ?. insertBefore ( link , headScript ) ; } ) ; } ; export { fetchPromiseStylesheet } ;