[annotator-dev] Lazy loading annotations

steph steph at endpoint.com
Tue Jul 22 15:53:22 UTC 2014


Hi Michael,

On 07/21/2014 09:25 PM, Head, Michael wrote:
> I’m working on a research project that uses Annotator to display annotations on academic articles. I'm experiencing some slowness when loading hundreds of annotations on a page. My research advisor is hoping the proof of concept we’re working on can scale up for hundreds of annotators with thousands of annotations.
>
> The code currently loads in all the annotations via an AJAX request after the page loads. The response is a 1.1MB JSON file that takes a while to parse. I have been trying to find a way to lazy load annotations in on scroll and I was wondering if something like this currently exists. Searching Google, this developer thread, and looking over Github issues hasn’t worked for me so far.
>
> I thought using a small Limit in the query would work fine, but querying that way returns the last X annotations that were created, which may be scattered anywhere in the viewport (in view or out of view of the user). What I’m trying to do is load only those annotations that should be in the current viewport, plus maybe a few more.
>
> Is there any way to do this that currently exists or would this require adding position (pixel offset) information to each annotation so that I can order by that when querying with a limit?
>

I don't believe there is a plugin that does what you are looking for.

The way I might approach this is by saving an additional field on the 
annotation, using the various annotator hooks (e.g. 
beforeAnnotationCreated) to save the position/pixel offset as part of 
the annotation, and load only those annotations that are visible or 
within a certain pixel offset with your query. It sounds like you 
already have a sense of how to do this.

Steph



More information about the annotator-dev mailing list