Some test text!

Hamburger Icon

Web / Guides / Optimize for production

Optimize & reduce lib folder for WebViewer

WebViewer comes bundled with the files required for all use cases. In many situations, all these files are not needed.

Optimize via script

A script comes packaged with Webviewer that can be used to delete any files that you will not be using. You can run this script by (at the root of your WebViewer folder) executing:

npm run optimize

The script will ask you a series of questions, and delete files based on your answers:

Do you want to exclude the use of optimized worker files? If you exclude them make sure that you pass 'enableOptimizedWorkers: false' to the WebViewer constructor.

Answer no to this question if you want use optimized workers or needing smaller file size.

Answer yes to this question to avoid using optimized workers.

Will you be using WebViewer Server?

Answer yes to this question if you will be using WebViewer Server .

Answer no if you will be using the default client only mode .

Will you be converting all your documents to XOD?

Answer yes to this question if you will be using a server to convert all your documents to the XOD format before viewing.

Answer no if you will be opening any format other than XOD.

Do you need client side office support?

Answer yes to this question if you want to support opening or converting Microsoft Office files (such as .docx, .pptx, xlsx).

Answer no if you do not need Microsoft office support.

Do you need the full PDF API?

We provide a full API that can process documents outside of the viewer.

Answer yes to this question if you need to access to the full API.

In most cases, you do not need the full API and can answer no to this question.

Do you need to deploy to Salesforce?

To be able to upload WebViewer source code to Salesforce as static resource files of 5 MB in size, we need to optimize and split up WebViewer code into separate chunks.

Answer yes to this question if you are planning to deploy to Salesforce platform and need to optimize WebViewer.

Answer no if you are not deploying to Salesforce platform.

Why does the folder size still seem large?

Note that the lib/core/pdf folder contains multiple versions of the same PDF SDK logic that are optimized for different browsers. The versions are:

Threaded Wasm Threaded WebAssembly. Currently only supported by Chrome but more browsers will support it in the future. Wasm: WebAssembly version for Edge, FireFox, iOS 11+ and Android Chrome 59+
asm.js: For IE11, iOS10-, Android Chrome 58-. This is the slowest version.

Only 1 of the 3 is actually loaded at runtime, so while your server would have all the files, each user would only download a subset of them.

Get the answers you need: Chat with us