Hi, I'm not sure if the issue is still happening; it's been a week, and it just crossed my mind 😄
Adding a 1ms delay might solve the problem – would you like to give it a try?
(It’s currently 8 AM local time for me, and I just woke up. I think I saw it in a dream 🥱)
setTimeout(() => {
document.addEventListener('DOMContentLoaded', () => {
const indexPage = document.querySelector('.IndexPage');
const carousel = document.querySelector('.carousel');
const hideCarousel = () => {
if (indexPage && indexPage.className.includes('IndexPage--tag')) {
carousel?.style.setProperty('display', 'none', 'important');
}
};
hideCarousel();
// check
const observer = new MutationObserver(hideCarousel);
observer.observe(document.body, { childList: true, subtree: true });
});
}, 1); // 1 ms
It solved issues in a previous JS code I wrote. Try increasing the 1ms delay up to 1000 and test it.
If it still doesn’t work, let me know. I have another idea: hiding it with CSS on all pages and then making it visible with JS only on the homepage – we can try that as well.