File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
// This script is for critical JS that needs to run as soon as possible.
2
- // Do not import any dependencies and keep to vanilla JS only.
2
+
3
+ let attempts = 0 ;
4
+ requestAnimationFrame ( function wait ( ) {
5
+ if ( document . querySelector ( 'script[src*="index.js"]' ) || ++ attempts > 100 ) return init ( ) ;
6
+ requestAnimationFrame ( wait ) ;
7
+ } ) ;
3
8
4
9
// This function runs before DOMContentLoaded and checks if most of the page
5
10
// has loaded so we can do DOM mutations before anything is painted on the screen.
6
- requestAnimationFrame ( function init ( elapsed ) {
7
- if ( elapsed > 10000 ) return ;
8
- if ( ! document . querySelector ( 'script[src*="index.js"]' ) ) return requestAnimationFrame ( init ) ;
9
-
11
+ function init ( ) {
10
12
// Synchronously set clone button states and urls here to avoid flickering
11
13
// on page load. initRepoCloneLink calls this when proto changes.
12
14
// this applies the protocol-dependant clone url to all elements with the
@@ -32,4 +34,4 @@ requestAnimationFrame(function init(elapsed) {
32
34
el . href = `vscode://vscode.git/clone?url=${ encodeURIComponent ( link ) } ` ;
33
35
}
34
36
} ) ( ) ;
35
- } ) ;
37
+ }
You can’t perform that action at this time.
0 commit comments