In general I’d advise against hiding the initial content since if you’re trying to embed a deleted Tweet you might find problems with hidden content on your page. However, if you still want to try to handle that there’re much simpler ways to interact with the widget states:
.twitter-tweet { display: none }
.twitter-tweet-rendered { display: block }
The -rendered classname variant will be appended to any widget classname when rendered.
However, if a Tweet is deleted or the service is down then there’s currently no functionality to annotate failed embed codes. We can look into adding it, but that’s not a priority right now. You’ll need to do your own timeout handling: Something like:
twttr.events.bind("rendered", function (e) {
if (e.target.tagName == "BLOCKQUOTE") {
e.target.style.display = "block";
}
}
And I guess you’ll want to handle timeouts or unexpected script failure to, so something like:
window.setTimeout(function () {
document.documentElement.classList.add("timeout-limit")
}, 5000);
.timeout-limit .twitter-tweet { display: block }
Alternatively, check out the [node:22530] documentation to style the embed codes more similarly to the final Tweet.