react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

Google Maps API call giving low lighthouse score

Open gaurav-agarwal27 opened this issue 6 years ago • 1 comments

I have wrapped my application with <LoadScript /> in my app.js as I need the package in multiple places across the application. When I run the lighthouse check on the site, it gives very low Performance score and says that main thread is blocked by 3rd-party scripts.

On blocking the maps.googleapis.com request, the score shows 90+ score most of the time. Is there any way I can defer / async the API call or improve the score in any way?

gaurav-agarwal27 avatar Nov 20 '20 10:11 gaurav-agarwal27

Yes, you can defer to render LoadScript until user interaction, for example pressing a button, or just setTimeOut in UseEffect or componentDidMount. Please do not forget to clearTimeout.

JustFly1984 avatar Nov 21 '20 20:11 JustFly1984