How to listen for onload event of the script?
2ico opened this issue · comments
I'd like to show a loading page while the script is loaded. How can it be done with this library?
First of all you need to load telegram SDK as soon as possible. In other words, you need to separate module telegram-web-apps from the rest code base and put it on the top of your HTML. Check out the example in our Boilerplate repo.
When it's done, just call WebApp.ready()
right after telegram-web-apps chunk execution:
<html>
<head>
<script src="telegram-web-apps.js"></script>
<script>WebApp.ready()</script>
</head>
<body>
<div>Loader</div>
<script src="app.js"></script>
</body>
</html>