Skip to content

Instantly share code, notes, and snippets.

@ebidel
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebidel/0e3ed2f9bb5f1ae9583d to your computer and use it in GitHub Desktop.
Save ebidel/0e3ed2f9bb5f1ae9583d to your computer and use it in GitHub Desktop.
Which is faster? <iframe style="display:none"> or <iframe><body style="display:none"></iframe>?

Blink aborts computing styles on descendants of display:none nodes. If the inside of the iframe has <body style="display:none">, you make remove recalc style, no layout, no painting. <iframe style="display:none"> still does all that work because it's another document and the display:none effect does not transcend into the other document.

@joseeight
Copy link

I don't get how these are related, they are completely two different things. If you hide the iFrame, you are obviously triggering a recalc of the parent document and elements around it, while the body of the document in the iFrame is separate and only that would be affected (fingers crossed). This is more of a question of what happens when the parent element has a set width and height and you want to hide the contents inside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment