Skip to content

Faster clear by running .textContent = "" after a rAF #166

@adamhaile

Description

@adamhaile

Discovered this one from vidom's fast "clear rows" result and thought I'd pass it on.

If you run .textContent = "" after a requestAnimantionFrame, it saves 35-40ms in the "clear rows" benchmark.

So tweaked vanillajs-keyed Main.clear() looks like:

    clear() {
        startMeasure("clear");
        this.store.clear();
        this.rows = [];
        this.data = [];
        var that = this;
        requestAnimationFrame(function () {
            that.removeAllRows();
            this.unselect();
        });
        stopMeasure();
    }

Same trick saves about 5ms in the "replace all rows" test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions