Preloading WebViewer library/worker files

When WebViewer is loaded with the initialDoc option, it will first load the large library resources, like PDF or Office workers, depending on the type of file you are trying to open, and then the file will be processed and displayed on the screen.

By default WebViewer will load the worker files lazily when needed but if WebViewer needs to be initialized without opening a file or if you will be loading both PDF and Office files, you can use the preloadWorker option to load the workers up front.

It is not recommended to use this option when WebViewer Server is enabled as certain clients (IE, mobile devices) will not want to load the PDF workers at all for performance reasons.

JavaScript

1WebViewer({
2 path: '../../../lib',
3 preloadWorker: 'pdf',
4 ...
5}, document.getElementById('viewer'))
6 .then(instance => {
7 // ...
8 });

Here WebViewer is displayed without opening a file but the PDF workers have still been loaded.

Apryse Docs Image

Preload MS Office workers

The MS Office workers are preloaded in the same way as PDF workers, you only need to change the preloadWorker option to "office". If you decide to preload both PDF and Office workers on the initial load change it to "all".

JavaScript

1WebViewer({
2 path: '../../../lib',
3 preloadWorker: 'office', // 'all' to preload both pdf & office workers
4 ...
5}, document.getElementById('viewer'))
6 .then(instance => {
7 // ...
8 });

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales