Page requests geolocation on load

Users are mistrustful of or confused by pages that automatically request their location on page load. Lighthouse flags when pages request geolocation permission on load:

Lighthouse audit showing geolocation request on page load
Page requests geolocation on load.

How this audit fails

Lighthouse collects the JavaScript that was executed on page load. If this code contains calls to geolocation.getCurrentPosition() or geolocation.watchPosition(), and geolocation permission was not already granted, then Lighthouse fails the audit.

Under URLs, Lighthouse reports the line and column numbers where your code is requesting the user's location. Remove these calls, and tie the requests to user gestures instead.

If geolocation permission was already granted to a page before Lighthouse's audit, Lighthouse cannot determine if the page requests the user's location on page load. Reset the permissions and run Lighthouse again. See Change website permissions for more help.

Each Best Practices audit is weighted equally in the Lighthouse Best Practices Score. Learn more in The Best Practices score.

How to ask for user's location responsibly

  • Assume users won't give you their location.
  • Use a fallback if geolocation is required.
  • Always request access to location on a user gesture, not on page load.
  • Give a clear indication that the action requests their location.

Learn more in Ask permission responsibly.

Each Best Practices audit is weighted equally in the Lighthouse Best Practices Score. Learn more in The Best Practices score.

More information

Page requests geolocation on load audit source

Last updated: Improve article