Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search performance #1385

Closed
wants to merge 1 commit into from
Closed

Improve search performance #1385

wants to merge 1 commit into from

Conversation

paulmelnikow
Copy link
Member

This change applies a unique ID to each badge example, and uses that to key the DOM.

Before this change, the key was the array index. While constant with the filter, it mutated as the filter changed, causing React to mutate the DOM very inefficiently. Badges were filtered out by mutating al the rows instead of simply removing the affected rows.

I first tried a version that applied a class with display: none to the hidden elements. That worked; however the implementation has a bunch of indirection, and this works nearly as well.

Fix #1314

This change applies a unique ID to each badge example, and uses that to key the DOM.

Before this change, the key was the array index. While constant with the filter, it mutated as the filter changed, causing React to mutate the DOM very inefficiently. Badges were filtered out by mutating al the rows instead of simply removing the affected rows.

I first tried a version that applied a class with `display: none` to the hidden elements. That worked; however the implementation has a bunch of indirection, and this works nearly as well.
@shields-ci
Copy link

Messages
📖

✨ Thanks for your contribution to Shields, @paulmelnikow!

Generated by 🚫 dangerJS

@paulmelnikow
Copy link
Member Author

Would appreciate some testing vs https://shields.io/ and https://shields-staging.herokuapp.com/!

@paulmelnikow
Copy link
Member Author

In my testing, https://shields.io/ is still faster, though https://shields-staging-pr-1385.herokuapp.com/ is much faster than https://shields-staging.herokuapp.com/.

@RedSparr0w
Copy link
Member

RedSparr0w commented Dec 22, 2017

1 thing i noticed that makes it feel slower is the images reloading when you remove letters:
image reloading

I think that gives the display: none route an advantage IMO, as the images shouldn't need to reload.

@paulmelnikow
Copy link
Member Author

Yea, agreed, that isn't great. However I don't believe it would happen in production, where LONG_CACHE is set.

@paulmelnikow
Copy link
Member Author

I pushed the other branch if you'd like to compare: #1393.

@paulmelnikow
Copy link
Member Author

Closing in favor of #1393.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants