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

Improved performance of click event breadcrumbs #2094

Merged
merged 5 commits into from Mar 18, 2024

Conversation

AnastasiiaSvietlova
Copy link
Contributor

Goal

Reduce time it takes gather innerText of a large element

Changeset

Updated RegExp for trimming whitespaces in breadcrumbs for UI click

Testing

Covered by existing unit tests

Copy link

github-actions bot commented Mar 8, 2024

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 43.70 kB 13.40 kB
After 43.69 kB 13.41 kB
± -5 bytes ⚠️ +2 bytes

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against 83bf8c9

@@ -21,8 +21,7 @@ module.exports = (win = window) => ({
}
})

const trimStart = /^\s+/
const trimEnd = /(^|[^\s])\s+$/
const trim = /^\s*([^\s].{0,139}[^\s])?\s*/s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lemnik looks like we've got an issue with this regex - perhaps the s at the end? it was modified slightly from the suggestion as it didn't remove the trailing whitespace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's certainly what the error indicated, although the /s flag is the dotAll flag. Maybe it's a version compatibility thing and we need to use [.\n] instead of . (assuming dotAll is not available on the target browser)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced . with [.\n] and tests failed locally.
For example:
Screenshot 2024-03-11 at 16 32 24

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/^\s*([^\s][\s\S]{0,139}[^\s])?\s*/

should do the trick, [\s\S] should be treated the same as . with the dotAll flag set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked! Thanks!

CHANGELOG.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like your linter has applied some formatting to older entries - can you revert so that only the new entry is added?

@AnastasiiaSvietlova AnastasiiaSvietlova merged commit cf57dd9 into next Mar 18, 2024
71 checks passed
@AnastasiiaSvietlova AnastasiiaSvietlova deleted the PLAT-11199-plugin-interaction-breadcrumbs branch March 18, 2024 14:06
@yousif-bugsnag yousif-bugsnag mentioned this pull request Apr 17, 2024
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.

None yet

4 participants