> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.spreadsimple.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to run custom JavaScript when app is ready?

How to run custom JavaScript when the website is ready?

Sometimes you need to run some JavaScript code after the website is fully rendered and all elements are ready for interaction.
If you run the code too early (before the web app is fetched all the data and complete rendering) most likely some elements will be missing or lack data.

That's why there is a special event `ssViewerRendered`

```
<script>
document.addEventListener('ssViewerRendered', () => {
  // put your code here
})
</script>```


A working example that opens the details page by clicking on the image:

```<script>
document.addEventListener('ssViewerRendered', () => {
  document.querySelectorAll('.sv-tile').forEach(tile => {
      tile.querySelector('.sv-tile__image').onclick = () => tile.querySelector('.sv-tile__btn').click()
  })
})
</script>```

This code should be added in [Settings](/en/article/settings-tab-cjcsjg/) tab. 