Skip to content

<Link> Component performance #1873

@khakulov

Description

@khakulov

Im my actual project i have to render a table with 300-400 rows. Every row contains a link to another page in my app. In actual beta4 version every rerendering of my table takes 400-500ms. Master brach is much better but still first rendering is to slow.

I looked deep in code by commenting out line by line the render function of Link component and realized that history.isActive takes to long to check active state of the link. Which state i don't need in my table.

The other small issue what i think is, that every link has onClick EventBindling. For every EventBinding browser allocates a small piece of memory. Which is no problem if the page has few links.

So i solved that problem for me, with normal html Tags and old school jQuery solution one global EventBinding on document which catches every link click and calls pushState if its realtive url (without http://):

$(document).delegate('a', 'click', evt => {
        if (evt.isPropagationStopped()) {
            return;
        }
        if(clickedWithoutHoldingAnyKeyboardButton(evt) && targetIsThisWindow(evt.target)) {
            let href = $(evt.target).attr("href");
            if (!isAbsoluteURL(href)) {
                evt.preventDefault();
                let [path, query] = parsePath(href);
                history.navigate({}, path, query);
            }
        }
});

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