Skip to content

Tracking script causes forced reflow of the page #5727

@mquandalle

Description

@mquandalle

Past Issues Searched

  • I have searched open and closed issues to make sure that the bug has not yet been reported

Issue is a Bug Report

  • This is a bug report and not a feature request, nor asking for self-hosted support

Using official Plausible Cloud hosting or self-hosting?

Plausible Cloud from plausible.io

Describe the bug

I noticed the following performance issue in Google PageSpeed insights for my site: https://pagespeed.web.dev/analysis/https-bonforfait-fr-forfait-mobile/cb3p4e98kp?utm_source=search_console&form_factor=mobile&hl=en

Image

This is caused by the the Plausible tracking script:

return Math.max(
body.scrollHeight || 0,
body.offsetHeight || 0,
body.clientHeight || 0,
el.scrollHeight || 0,
el.offsetHeight || 0,
el.clientHeight || 0
)

This code is used in the getDocumentHeight function to track scrolling position.

Expected behavior

I'd like to avoid performance this penalty.

Maybe it is possible to wrap the getDocumentHeight function in a requestAnimationFrame? And to cache its value?

An alternative would be having the option to disable scroll tracking.

Screenshots

No response

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions