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

Optimize OneTrust rule #282

Open
muodov opened this issue Nov 10, 2023 · 1 comment
Open

Optimize OneTrust rule #282

muodov opened this issue Nov 10, 2023 · 1 comment
Labels
CMP help wanted Extra attention is needed performance Improve performance of an existing feature

Comments

@muodov
Copy link
Member

muodov commented Nov 10, 2023

OneTrust is by far the most common CMP, but right now it contains huge delays (seconds), so opting out works, but is super slow. This sometimes blocks the website for a few seconds. We should review it and see if it can be optimized.

Here's what I found last time I checked:
After clicking the options button, we need to wait until the pop-up is visible. This is tricky (e.g. on stackoverflow.com) as our waitForVisible() function fails there, so we resort to really long unconditional delays, which cause most of the slow down.
As far as I know, there's no universal way to check the element "visibility" in DOM. We can probably come up with a hack specifically for stackoverflow, but we should be careful not to break the rule on other sites. Some example sites can be found in the monthly crawl data and the test files.

@muodov muodov added help wanted Extra attention is needed performance Improve performance of an existing feature CMP labels Nov 10, 2023
@sbeesm
Copy link

sbeesm commented Feb 6, 2024

Hello, I spent some time looking into this and wanted to share my observation.

As OneTrust waits with waitForElement('#onetrust-consent-sdk', 2000) here and given onetrust-consent-sdk is the parent div for consent selection related elements, it seems that because this div is already present when the site loads, the process does not listen for changes after clicking the options button and immediately proceeds to select the checkboxes, submit and occasionally fails.

image

Instead of waitForElement(), we could consider using waitForVisible() on #onetrust-pc-sdk. This is the div that shows up on clicking the options button ("Customize Settings") and encapsulates pop-up related elements.

Using this would also eliminate the need to wait for save-preferences button here and the unconditional delays as all the checkboxes and save button are part of a child div - which is expected to be visible if the parent div is visible. I see similar behavior for other sites using this CMP like technologyreview.com.

image

I tested this change on my local and it works fine. But I was not able to reproduce the issues for which the unconditional delays were added (for example the popup still being visible after consent was denied successfully), so it is difficult to the test that behavior with this change.

Also, as some sites like stackoverflow.com are providing a "Reject All/Necessary Only" option upfront, this optimization might not be required in future.

I would appreciate hearing your thoughts on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMP help wanted Extra attention is needed performance Improve performance of an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants