Skip to content

Faster highlight creation #523

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

Merged
merged 2 commits into from
May 3, 2015

Conversation

wjt
Copy link
Contributor

@wjt wjt commented May 1, 2015

Not the big reorganisation discussed on #521 but this fixes a different big bottleneck for me.

There must be some reason you are calling .show() on all the spans – perhaps defending against the page having some CSS which applies to all spans and hides them or something like that? I'm not sure how big a problem this is in practice, or how to work around it without calling .show() – set a defensive display: inherit; on span.annotator-hl and hope that there's no more specific style in effect?

wjt added 2 commits April 30, 2015 21:36
I don't understand why this would be necessary -- the element's just
been created, no style is (presumably) changing its display to anything
other than the default... -- and when highlighting all text in a 5000×3
table, $.show() accounts for 10s out of the 14s it takes to draw the
highlights.

$.show() being absurdly slow is a known problem:
jquery/jquery.com#88
This funtion accounted for ~1 second of the remaining time in my 5000×3
table test case. With this change it's more like 200ms, which is still
not ideal but a lot better.

$.wrapAll seems relatively expensive. I suppose it has to do lots of
extra work that's not necessary when we know we have exactly one element
to wrap at a time.
@nickstenning
Copy link
Member

Just about to hop on a plane, but this looks fine to me. I can't see any reason to call .show() here -- perhaps it's been grandfathered in?

@tilgovi
Copy link
Member

tilgovi commented May 3, 2015

👍 from me.

tilgovi added a commit that referenced this pull request May 3, 2015
@tilgovi tilgovi merged commit e355de6 into openannotation:master May 3, 2015
@tilgovi
Copy link
Member

tilgovi commented May 3, 2015

Use of the global document broke the linting so I replaced it with util.getGlobal().document). We should evaluate whether we can replace getGlobal() since it breaks CSP and it might be a bottleneck if we're calling it all the time.

mwidner added a commit to PoeticMediaLab/annotator that referenced this pull request Nov 19, 2015
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