Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: INP issue in Google Search Console #738

Open
bennetsadyba opened this issue Oct 1, 2024 · 1 comment
Open

[Bug]: INP issue in Google Search Console #738

bennetsadyba opened this issue Oct 1, 2024 · 1 comment
Labels
bug Something isn't working triage yet to be reviewed

Comments

@bennetsadyba
Copy link

bennetsadyba commented Oct 1, 2024

Expected Behavior

No INP issues in Google Search Console, INP below 200ms

Current Behavior

Google Search Console (Core Web Vitals) reports a problem with INP: "INP issue: longer than 200ms (mobile)".
The problem regards the action of pushing Accept button. You can confirm the problem with debugbear inp-debugger report. Correct me if I'm wrong, but I suspect that click action triggers some code that takes long to process (long in terms of INP metric).

consent

Duration breakdown:
Input Delay | 28 ms
Processing Time | 50 ms
Presentation Delay | 130 ms

I might have found the bottleneck, however the script is minified and thous hardly readable. The click event takes a lot of time.

Recalc
recalc2

There is as whole article on this topic at https://web.dev/articles/cookie-notice-best-practices

Steps to reproduce

Either look into your Google Search Console - Core Web vitals Report, or use debugbear inp-debugger report.

Proposed fix or additional info.

The proposed solution is to defer code execution. So visually code looks like it has been executed successfully while some work is still underway in the background.

The logic is as follows:

function saveSettings () {
  // Do critical work that is user-visible:
  validateForm();
  showSpinner();
  updateUI();

  // Defer work that isn't user-visible to a separate task:
  setTimeout(() => {
    saveToDatabase();
    sendAnalytics();
  }, 0);
}

Version

3.0.0

On which browser do you see the issue?

No response

@bennetsadyba bennetsadyba added the bug Something isn't working label Oct 1, 2024
@github-actions github-actions bot added the triage yet to be reviewed label Oct 1, 2024
@bennetsadyba
Copy link
Author

One more thing - the function that replaces <script src= should be run with a delay after consent button click. This might be the function "manageScriptTags". This will improve INP furthermore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage yet to be reviewed
Projects
None yet
Development

No branches or pull requests

1 participant