van
van copied to clipboard
Possible size reduction
In this code
you can avoid the dom.remove()
by simply doing dom.replaceWith('')
So it can be replaced as
let update = (dom, newDom) => newDom === dom || dom.replaceWith(newDom||'')
Also, there is many time the document
variable in the script. Maybe it's worth creating an alias, since it won't be renamed by the minifier code, like this :
let dom = ns ? document.createElementNS(ns, name) : document.createElement(name)
// instead:
let d=document,dom = ns ? d.createElementNS(ns, name) : d.createElement(name)
// Or better:
let n = ns&&'NS', doc = document['createElement'+n](ns||name,name)
And finally, k.startsWith("on")
appears twice in the same method, and is longer than an alias let o=k.startsWith('on')
so it can be further optimized away.
Anyway, thanks for the library, it's very useful.