Widget missing on dynamically loaded content
The widget initialises once, when the page loads. Anything added to the page afterwards by JavaScript never gets processed, so the ratings are missing on it.
You will hit this with:
- infinite scroll on category and listing pages,
- AJAX filters that replace the product grid without reloading the page,
- single-page apps (React, Vue, Next.js in client-side routing) where navigation does not reload the document,
- quick view and modal windows built on the fly.
The fix: reinitialise after the new content arrives
Call the init function again once the new elements exist in the DOM. Use the same user ID and settings as your original snippet, and target the newly added container.
<script> // Wywolaj to PO doladowaniu nowych kart, nie przy starcie strony. function refreshJustReview() { initStars("YOUR_USER_ID", { /* the same settings as your snippet */ }); }</script>Where you call it depends on your platform:
Infinite scroll or AJAX filters. Most scripts fire an event or accept a callback when the new
batch is inserted. Call refreshJustReview() there.
A generic fallback: watch the container. When there is no event to hook into, observe the grid and reinitialise when new nodes appear.
<script> var grid = document.querySelector('#product-grid'); // your container if (grid) { new MutationObserver(function () { refreshJustReview(); }).observe(grid, { childList: true }); }</script>Single-page apps. Call it after each route change, in the hook your framework gives you for “navigation finished”.
Widget worked and then stopped completely
That is a different problem. Check, in order:
- Your domain whitelist in Settings still matches your
address. A migration from
httptohttps, or addingwww, changes it. - The container element is still on the page. Theme updates and page-builder edits remove it surprisingly often.
- A caching or optimisation plugin started deferring, combining or minifying the script. Exclude
justreview.jsfrom JavaScript optimisation. - The snippet was regenerated in the dashboard but not replaced on your site, so it still carries old settings.