# Don't load annotations on document load

**URL:** <https://pdfjs.community/t/dont-load-annotations-on-document-load/2818>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [August 31, 2023, 1:40pm UTC](https://pdfjs.community/t/dont-load-annotations-on-document-load/2818 "2023-08-31T13:40:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user45](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@user45](https://pdfjs.community/u/user45)\
**Post date:** [August 31, 2023, 1:40pm UTC](https://pdfjs.community/t/dont-load-annotations-on-document-load/2818/1 "2023-08-31T13:40:48Z")

</div>

**Which product are you using?**  
PDF.js Express

**PDF.js Express Version**  
8.7.0

**Detailed description of issue**  
I try to load document to viewer and next import (and show) only my custom xfdf annotations, but when the pdf already has annotation they are loaded first.

**Expected behaviour**  
Annotations already contained in the file are not loaded, or they are deleted immadiantely after document loaded.

Manual removing all annotation after documentloaded event not works because annotations are showed later. Moreover annotationsLoaded event is never fired.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [August 31, 2023, 3:16pm UTC](https://pdfjs.community/t/dont-load-annotations-on-document-load/2818/3 "2023-08-31T15:16:48Z")

</div>

Hi there,

Thank you for reaching out to pdf.js express,

Please check this guide out for the lifecycle of the viewer:

> **[PDF.js Express Viewer Events | Documentation](https://pdfjs.express/documentation/learn-more/events.8)**

documentLoaded event will always trigger first before the annotationLoaded event. This means you have to wait for the annotationLoaded event to trigger before you can delete the annotations in the document.  
I.e.

```javascript
const { documentViewer } = instance.Core;
documentViewer.addEventListener('annotationsLoaded', () => {
  // you can delete annotations here 
  // then you can import your custom xfdf annotations 
})

```

Best regards,  
Kevin Kim
