2 ms·
Further size reduction, you don't need the `this.` on the inline event listener, so it can be: `contentWindow.location.hash` and `contentDocument.body.childNode
by err4nt 3y ago
Further size reduction, you don't need the `this.` on the inline event listener, so it can be: `contentWindow.location.hash` and `contentDocument.body.childNodes` instead of `this.contentWindow.location.hash` or `this.contentDocument.body.childNodes`.
This will shave another 10 bytes off the snippet :D
- niutech 3y agoIf you write `document.querySelector(contentWindow.location.hash||null)?.outerHTML=contentDocument.body.innerHTML`, you'll make it even shorter.
- ericlewis 3y agoWe can bring that down to 16 since query selector can handle undefined. 12% reduction. setTimeout(()=>document.querySelector(contentWindow.location.hash)?.replaceWith(...contentDocument.body.childNodes))
- Kalabasa 3y agoYeah, querySelector(undefined) works Although location.hash defaults to the empty string '' when there is no hash, which gives a SyntaxError, so we still need the fallback selector to select none.