It was a race condition. I render the twitter embed in a container of fixed size so there isn't layout shift. I then use an "onload" callback to determine when the iframe loads to detect if there's overflow. If there's overflow, I display the button to expand the container. It appears that the onload callback was being triggered before the content loaded in a way that would allow me to measure its height. The fix was just to assume that the container always has overflow (which it will) and always display the button following onload.