Dynamic content integration is a powerful feature, but it's crucial to understand its impact on performance. Using APIs and JavaScript to load content after the initial page request can negatively affect PageSpeed scores and loading times. Therefore, this approach is best suited for updating specific page sections based on user interactions after the initial page load. A prime example is a blog list that dynamically loads subsequent entries when the user clicks on pagination.
For optimal performance and top scores in Google Lighthouse and PageSpeed, the complete page content should be delivered in the initial server response. To incorporate dynamic content from databases or external sources, PagibleAI CMS provides actions. These are PHP classes designed to supply dynamic data for your Blade templates or JSON API responses.
Note: Pages are fully cached if their GET requests doesn't contain any URL query parameters! Therefore, adding random content isn't possible when using action classes, so use Javascript to fetch and/or display random content in that case.