ngxson HF staff commited on
Commit
58e4ac1
·
1 Parent(s): 3a7868c

add doc onload

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -157,12 +157,16 @@ API_NAME = 'tts'
157
 
158
  head = f'''
159
  <script>
160
- if (!localStorage.getItem('debug')) {{
161
- const frontendApp = document.createElement('iframe');
162
- frontendApp.src = '/gradio_api/file=./front/dist/index.html';
163
- frontendApp.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: none; z-index: 999999;';
164
- document.body.appendChild(frontendApp);
165
- }}
 
 
 
 
166
  </script>
167
  '''
168
 
 
157
 
158
  head = f'''
159
  <script>
160
+ document.addEventListener('DOMContentLoaded', () => {{
161
+ console.log('DOM content loaded');
162
+ if (!localStorage.getItem('debug')) {{
163
+ console.log('Attaching frontend app');
164
+ const frontendApp = document.createElement('iframe');
165
+ frontendApp.src = '/gradio_api/file=./front/dist/index.html';
166
+ frontendApp.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: none; z-index: 999999;';
167
+ document.body.appendChild(frontendApp);
168
+ }}
169
+ }});
170
  </script>
171
  '''
172