Blog2020 ≫ Slight tweak to the clever iframe inlining

Here's my slight improvement to the inlining I use for the sidebar over there 👉.. this is how the sidebar comments etc are always up to date without me having to regenerate every page of this static site every time.

 <iframe src="/misc/sidebar2/" onload="a=this;b=a.contentDocument;a.before((b.body||b).children[0]);a.remove()"></iframe>

I can't remember where I got this code from originally, I think it was here1, but it starts off as an iframe, then the content of the iframe pops right into the page. By the time you see it2 it's no longer an iframe, the content is really in the page.

My original tweak was to save a few chars assigning this to a variable and now I realise I can save a bit more. It's useful as it is repeated so much, every little helps.

⬅️ :: ➡️

Paul Clarke's blog - I live in Hythe near Folkestone. Wed to Clare + dad to 2, I am a full-stack web engineer, + I do js / nodejs, some ruby, other languages ect ect. I like pubbing, running, eating, home automation + other diy stuff, history, family tree stuff, TV, squirrels, pirates, lego, and TIME TRAVEL.