export const injectScript = ( { url , resolve , reject , } ) => { const element = document . createElement ( 'script' ) ; element . src = url ; element . async = true ; element . type = 'text/javascript' ; element . onload = ( ) => { resolve ?. ( null ) ; document . head . removeChild ( element ) ; } ; element . onerror = ( ) => { document . head . removeChild ( element ) ; reject ?. ( `Script Error: ${ url }` ) ; } ; document . head . appendChild ( element ) ; } ;