{"action":"created","issue":{"url":"https://api.github.com/repos/DenisKolodin/yew/issues/374","repository_url":"https://api.github.com/repos/DenisKolodin/yew","labels_url":"https://api.github.com/repos/DenisKolodin/yew/issues/374/labels{/name}","comments_url":"https://api.github.com/repos/DenisKolodin/yew/issues/374/comments","events_url":"https://api.github.com/repos/DenisKolodin/yew/issues/374/events","html_url":"https://github.com/DenisKolodin/yew/issues/374","id":354182435,"node_id":"MDU6SXNzdWUzNTQxODI0MzU=","number":374,"title":"How to have fast-loading static landing page before launching wasm app?","user":{"login":"Boscop","id":535593,"node_id":"MDQ6VXNlcjUzNTU5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/535593?v=4","gravatar_id":"","url":"https://api.github.com/users/Boscop","html_url":"https://github.com/Boscop","followers_url":"https://api.github.com/users/Boscop/followers","following_url":"https://api.github.com/users/Boscop/following{/other_user}","gists_url":"https://api.github.com/users/Boscop/gists{/gist_id}","starred_url":"https://api.github.com/users/Boscop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Boscop/subscriptions","organizations_url":"https://api.github.com/users/Boscop/orgs","repos_url":"https://api.github.com/users/Boscop/repos","events_url":"https://api.github.com/users/Boscop/events{/privacy}","received_events_url":"https://api.github.com/users/Boscop/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-27T05:15:25Z","updated_at":"2018-09-02T11:52:45Z","closed_at":"2018-09-02T11:51:47Z","author_association":"NONE","body":"I want to reduce the perceived first-load time of my wasm app and thought a good way would be to have a static landing page that has a button to enter the actual app (the wasm file should be loaded in the background while the user is looking at the static landing page).\r\n\r\nWhat's the best way to do this **without** redirects or serving the landing page and wasm app from different routes?\r\n\r\nInstead of mounting to body automatically immediately after compiling the wasm file, I want to have a static content as body which contains a button that causes the yew app to mount itself to body (overwriting the static content). \r\n\r\nHow to trigger this mounting from outside?\r\n\r\nShould I use stdweb's [`window().add_event_listener()`](https://docs.rs/stdweb/*/stdweb/web/trait.IEventTarget.html#method.add_event_listener) to register an event handler (in my `main()` function) that listens on the window for a [CustomEvent](https://developer.mozilla.org/en/docs/Web/API/CustomEvent) and only executes this code when that event was fired?\r\n```rust\r\n\tyew::initialize();\r\n\tApp::<AppRootComponent>::new().mount_to_body();\r\n\tyew::run_loop();\r\n```\r\n\r\n(And then raise that custom event in the \"Enter\" button's `onclick` handler in the static html page.)\r\n\r\nWould it cause problems because `yew::run_loop()` doesn't return, so my `CustomEvent` handler also won't return?\r\n\r\n---\r\n\r\nBut when the user has slow internet and clicks the button before the wasm file is loaded/compiled/executed, nothing would happen, even if the wasm app starts running shortly after. \r\nSo that button should set a global var as flag and that var should be read by my `main()` function in a spin-lock way? What's the best way to wait until that var is set, without waiting longer than necessary and without causing high cpu usage?"},"comment":{"url":"https://api.github.com/repos/DenisKolodin/yew/issues/comments/417925293","html_url":"https://github.com/DenisKolodin/yew/issues/374#issuecomment-417925293","issue_url":"https://api.github.com/repos/DenisKolodin/yew/issues/374","id":417925293,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzkyNTI5Mw==","user":{"login":"Boscop","id":535593,"node_id":"MDQ6VXNlcjUzNTU5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/535593?v=4","gravatar_id":"","url":"https://api.github.com/users/Boscop","html_url":"https://github.com/Boscop","followers_url":"https://api.github.com/users/Boscop/followers","following_url":"https://api.github.com/users/Boscop/following{/other_user}","gists_url":"https://api.github.com/users/Boscop/gists{/gist_id}","starred_url":"https://api.github.com/users/Boscop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Boscop/subscriptions","organizations_url":"https://api.github.com/users/Boscop/orgs","repos_url":"https://api.github.com/users/Boscop/repos","events_url":"https://api.github.com/users/Boscop/events{/privacy}","received_events_url":"https://api.github.com/users/Boscop/received_events","type":"User","site_admin":false},"created_at":"2018-09-02T11:52:45Z","updated_at":"2018-09-02T11:52:45Z","author_association":"NONE","body":"Ok. But I will use a pure CSS spinner instead of a GIF, so that it's faster to load :)"}}
{"actor":{"display_login":"Boscop"}}