File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 38
38
return ;
39
39
}
40
40
41
- document . addEventListener ( 'DOMContentLoaded' , function ( ) {
42
- console . log ( 'DOM Content Loaded - Initializing vote comment storage' ) ;
41
+ // Function to initialize the storage functionality
42
+ function initializeStorage ( ) {
43
+ console . log ( 'Initializing storage functionality' ) ;
43
44
44
45
const commentField = document . getElementById ( 'vote-comment' ) ;
45
46
if ( ! commentField ) {
95
96
} else {
96
97
console . error ( 'Could not find parent form element' ) ;
97
98
}
99
+ }
100
+
101
+ // Try to initialize immediately if DOM is already loaded
102
+ if ( document . readyState === 'complete' || document . readyState === 'interactive' ) {
103
+ console . log ( 'DOM already loaded, initializing immediately' ) ;
104
+ initializeStorage ( ) ;
105
+ }
106
+
107
+ // Also set up the DOMContentLoaded listener as a backup
108
+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
109
+ console . log ( 'DOM Content Loaded event fired' ) ;
110
+ initializeStorage ( ) ;
98
111
} ) ;
112
+
99
113
} catch ( e ) {
100
114
console . error ( 'Error in vote comment storage script:' , e ) ;
101
115
}
You can’t perform that action at this time.
0 commit comments