Very cool!
Can I recommend https://cdnjs.cloudflare.com/ajax/libs/eqcss/1.5.0/EQCSS.min.js
for your second line for better performance + SSL support? I feel like this will be helpful for a lot of folks who hit the following issue in Wordpress embeds as well.
Also I should mention that while this is a cool technique, there is a method in Hype using Groups + Scaling that supports this behavior without code.