This is happening because the iframe element is moved in the DOM after it renders. iframe elements, which we use to render widgets, have a restriction wherein if they are moved in the DOM after rendering, the entire body of the iframe is obliterated.
The usual workaround is to render the tweet after you have finished moving the elements in your DOM. Once you are done with that and ready to render a tweet, you can use the factory function to do it. Another way is to use the autoload parameter to control when to render.