Skip to content

Possible size reduction #359

Open
Open
@X-Ryl669

Description

@X-Ryl669

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions