Since Angular Universal isn't going to be in the CLI for quite a while I must use prerender.io to allow SEO to work properly. However, after some tests it appears that it doesn't work all that great because it doesn't appear to wait for lazy loaded modules so the SEO still fails.
On their site at this location, they say this:
Is your page only partially rendered?
Our Prerender server tries its best to determine when the page is done loading by counting the number of requests in flight. Once the number of requests in flight reaches zero, we wait a short period of time and then save the HTML. If this is saving the page too early, you can use our window.prerenderReady flag to notify the server that your page is ready to be saved.
Put this in your HTML:
<script> window.prerenderReady = false; </script>
When we see window.prerenderReady set to false, we'll wait until it's set to true to save the HTML. Execute this when your page will be ready (usually after ajax calls):
window.prerenderReady = true;
Here's where I don't understand how to go about it. Since Angular removes script tags from the template (not sure if this is just CLI behavior or Angular itself), I can't set the initial script tag. Nor can I figure out how I would update the window
property prerenderReady
inside a template script tag from my component class, since I can't just use window.prerenderReady = true
and expect it to work since the script has to be added to the template.
Has anyone managed to figure this one out or have any ideas on how I could achieve this?