File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
src/dashboard/Data/Browser Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -857,18 +857,18 @@ export default class DataBrowser extends React.Component {
857857 link . as = mediaType ;
858858 link . href = url ;
859859
860+ link . onload = ( ) => {
861+ // Resource successfully cached, safe to remove the link element
862+ link . remove ( ) ;
863+ } ;
864+
860865 link . onerror = ( ) => {
861866 console . error ( `Failed to prefetch ${ mediaType } : ${ url } ` ) ;
867+ // Failed to fetch, remove the link element
868+ link . remove ( ) ;
862869 } ;
863870
864871 document . head . appendChild ( link ) ;
865-
866- // Clean up the link element after a delay to prevent memory leaks
867- setTimeout ( ( ) => {
868- if ( link . parentNode ) {
869- link . parentNode . removeChild ( link ) ;
870- }
871- } , 30000 ) ; // Remove after 30 seconds
872872 } ) ;
873873 }
874874
You can’t perform that action at this time.
0 commit comments