As Angular Universal is not expected to be included in the CLI for some time, I've had to resort to using prerender.io in order to ensure proper SEO functionality. However, my tests have shown that there are issues with lazy loaded modules causing SEO failures.
According to information on their website located here, Prerender.io states:
Is your page only partially rendered?
Our Prerender server does its best to detect when a page has finished loading by monitoring the number of active requests. Once this count reaches zero, we pause briefly before saving the HTML content. If you find that the page is being saved too soon, you can use the window.prerenderReady flag to signal to the server that your page is ready for saving.
Add this code snippet to your HTML:
<script> window.prerenderReady = false; </script>
When we observe window.prerenderReady set to false, we will wait until it becomes true before saving the HTML content. Trigger this change once your page is fully loaded (usually after any ajax calls):
window.prerenderReady = true;
The challenge lies in implementing this solution within an Angular environment, specifically when script tags are removed from templates. It's unclear whether this behavior is specific to the CLI or inherent in Angular itself. Additionally, updating the window property prerenderReady within a template script tag from a component class poses difficulties, as simply setting window.prerenderReady = true may not function as intended without inclusion in the template.
Has anyone encountered and resolved this issue, or do you have suggestions on how I could address it effectively?