3 ms·
A remark for JavaScript developers: for injecting its content into the body, this script creates a dummy div (it has no attributes and is targeted by no styles)
by chrismorgan 6y ago
A remark for JavaScript developers: for injecting its content into the body, this script creates a dummy div (it has no attributes and is targeted by no styles), sets its innerHTML, then appends it to the body. That dummy div is actually unnecessary: Element.insertAdjacentHTML lets you achieve the same effect without it:
document.body.insertAdjacentHTML('beforeend', '<div class="nightnight">…</div>');
Browser support is universal. (Firefox was last to the game, getting it in Firefox 8, 9½ years ago. IE introduced it, in version 4.)
I have more remarks I could make, but I’ll leave it at that one. It’s the most interesting.
- sushid 6y agoWhat are some other remarks? Please do tell!
- throwaddzuzxd 6y agoInteresting, I've never heard of insertAdjacentHTML before. Thank you for sharing :)