-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
[docs–infra] Prevent displaying multiple ads #37696
[docs–infra] Prevent displaying multiple ads #37696
Conversation
'& [id^=carbonads_]': { | ||
display: 'none', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix, it works because of this logic in the ad script:
var n = document.getElementsByClassName("carbon-wrap");
var fdiv = document.createElement("div");
fdiv.id = n.length > 0 ? "carbonads_" + n.length : "carbonads";
fdiv.appendChild(el);
https://cdn.carbonads.com/carbon.js?serve=CKYIL27L&placement=material-uicom
c95ae86
to
1e468b4
Compare
Netlify deploy previewhttps://deploy-preview-37696--material-ui.netlify.app/ Bundle size report |
'& [id^=carbonads_]': { | ||
display: 'none', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'& [id^=carbonads_]': { | |
display: 'none', | |
}, | |
'&>div': { | |
display: 'none', | |
}, |
Maybe more solid since it does not rely on how carbon manages its multiple ads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be based on
&>div: { display: 'hidden' },
&>div:last-of-type: { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the approach, this should be more resilient, inspired by your comment.
Fix https://www.notion.so/mui-org/Trip-report-React-Summit-2023-18a3abdb83af4284b2d12f4deed18787?pvs=4#4554193ff13e46878e7f8b3e55db5d12, it was reported by a developer at React Summit, and something I experience every now and then too. Typically, it would look like this:
You can be reproduced easily by opening https://mui.com/material-ui/getting-started/overview/ and running
window._carbonads.init()
. In real life, this happens because the script runs asynchronously, so if you have a slow connection, and quickly switch to a different page, you will see it.