Optimize & reduce lib folder for WebViewer

WebViewer comes bundled with the files required for all use cases. In many situations, some of 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:

sh

1npm install
2npm run optimize

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

All questions listed may not be asked.

  • Do you want us to back up your files before optimizing?
    • Answer no to this question if you don't need to back up your files first.
    • Answer yes to this question if you do need to back up your files first.
  • Will you be using WebViewer Server?
  • 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 (docx, pptx, xlsx)?
    • 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 client side office support for legacy office files (doc, ppt, xls)?
    • Answer yes to this question if you want to support opening or converting Microsoft Office legacy files (such as .doc, .ppt, xls).
    • Answer no if you do not need Microsoft office support for legacy files.
  • 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 want to use the product version of PDFnet.js?
    • Answer yes to this question if you don't need to access to type checking or console messages and would like a smaller version than the development version.
    • Answer no if you do need access to type checking or console messages and want the larger development version.
  • Do you need to use the content editing feature?
    • Answer yes to this question if you want to use the content editing feature.
    • Answer no if you do not want to use the content editing feature.
  • Do you need to use the office editing feature?
    • Answer yes to this question if you want to use the office editing feature.
    • Answer no if you do not want to use the office editing feature.
  • Do you need to use the spreadsheet editing feature?
    • Answer yes to this question if you want to use the spreadsheet editing feature.
    • Answer no if you do not want to use the spreadsheet editing feature.
  • 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.
  • 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 to use optimized workers, need a smaller file size, or want more efficiency.
    • Answer yes to this question to avoid using optimized workers.

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.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales