In Marketo guided landing pages, using the "hide" feature (via display: none) does not remove the hidden sections from the page's HTML. Instead, these sections—along with their resources like images, scripts, and styles—are still loaded by the browser, leading to performance issues and heavier templates.
I came across this discussion: Removing a Landing Page Element Instead of Just Hiding It, but it didn’t work for us.
Has anyone successfully implemented a method to fully remove these sections from the final HTML output? Are there best practices or alternative approaches to achieve this?
Do you have any details for why it didn't work? I use the comment method (messing with "<!-- --> via tokens) all of the time.
Another method not discussed is javascript to render HTML after the page loads, but if you are worried about performance you are better off just making new versions of the templates.
Wait a couple of days and I'll put our preferred method up on the Products blog. This method makes the hidden elements fully inert, meaning subresources like images and scripts will not be loaded. (It doesn't simply comment out elements, because as convenient as that seems, it breaks if there are comments in the element itself!)
As @Legitster mentions, an even more interesting approach is dynamically loading the HTML only for enabled elements, which we call “partials,” but it's quite complex to implement.