# Can we significantly reduce the memory?

**URL:** <https://community.apryse.com/t/can-we-significantly-reduce-the-memory/3605>\
**Category:** WebViewer\
**Created:** [June 17, 2020, 7:47pm UTC](https://community.apryse.com/t/can-we-significantly-reduce-the-memory/3605 "2020-06-17T19:47:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Parizeau](https://community.apryse.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@Matt\_Parizeau](https://community.apryse.com/u/Matt_Parizeau)\
**Post date:** [June 17, 2020, 7:47pm UTC](https://community.apryse.com/t/can-we-significantly-reduce-the-memory/3605/1 "2020-06-17T19:47:12Z")

</div>

Hi Ricky,

Currently we don’t support splitting of the modules when certain features aren’t being used. This is a longer term thing that we’re looking into but don’t yet have a timeline for when it would be available.

For loading multiple instances of WebViewer on the same page the main thing that you can do to save memory is to share the PDF worker objects across all viewer instances. Here are the steps to do this:

1. Include a script tag pointing to webviewer-core.min.js directly on your app’s HTML page. webviewer-core.min.js is normally only loaded inside the iframe but in this case we also need to load it on your app’s page so that we can create the workers there.
2. Use code similar to the following when instantiating your WebViewer instances. Basically you need to create a “worker transport promise” which will be passed to each WebViewer instance. This will allow each instance to share the same worker. The worker path may need to be adjusted as it will be relative to your HTML file. In this example I modified the viewing sample included in the WebViewer download package but you may need to adjust the path.

```auto
Core.setWorkerPath('../../../lib/core');

Core.getDefaultBackendType().then((backendType) => {
  const workerHandlers = {};
  const licenseKey = 'LICENSE_KEY_HERE';

  const workerTransportPromise = Core.initPDFWorkerTransports(backendType, workerHandlers, licenseKey);

  WebViewer({
    path: '../../../lib',
    licenseKey,
    initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
    workerTransportPromise: {
      pdf: workerTransportPromise
    }
  },
  document.getElementById('viewer')).then(instance => {
    samplesSetup(instance);
  });

  WebViewer({
    path: '../../../lib',
    licenseKey,
    initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
    workerTransportPromise: {
      pdf: workerTransportPromise
    }
  },
  document.getElementById('viewer2')).then(instance => {
    samplesSetup(instance);
  });
});

```

Matt Parizeau  
Software Developer  
PDFTron Systems Inc.
