Google Pagespeed score issues

Thanks for the information provided, Kyle!

Unfortunately, I need to tell you that there’s no possibility to reduce the unused JavaScript size, I’m really sorry about it. The thing is that the majority of our widgets, including Google Reviews widget, have hidden functionality that is not used all the time but activated when needed. For example, the Google Reviews widget uses cache and updates once every 48 hours. Between the update period, the part of the code used for it is considered unused by Google PageSpeed.

However, you are very welcome to reinstall your widget by using some kind of lazy loading. Though, please keep in mind that this way of installation won’t meet your needs in case you would like to display your static widget above the fold.

Here is your installation code:

<div id="widgetContainer"></div>
<script src="https://apps.elfsight.com/p/platform.js" defer></script>
<script>
function inViewport(element){
const bb = element.getBoundingClientRect();
return !(bb.top > innerHeight || bb.bottom < 0);
}

let widgetVisible = false;
const widgetContainer = document.querySelector('#widgetContainer');

document.addEventListener('scroll', event => {
if (inViewport( widgetContainer ) && !widgetVisible){
widgetVisible = true;
const widget = document.createElement('div');
widget.className = "elfsight-app-WIDGET_ID ";
widgetContainer.append(widget);
}
});
</script>

Please replace WIDGET_ID in the code above with the ID of your own widget and add this code to your website backend right to the place where you’d like to display the widget.

Please let me know if you have other questions!Preformatted text

2 Likes