Edit

Share via


Reduce JavaScript by excluding unused modules

Note

The Retail Interest Group by Dynamics 365 Commerce has moved from Yammer to Viva Engage. If you don't have access to the new Viva Engage community, fill out this form (https://aka.ms/JoinD365commerceVivaEngageCommunity) to be added and stay engaged in the latest discussions.

This article describes how you can help improve performance by reducing the amount of JavaScript used in your Microsoft Dynamics 365 Commerce implementation.

Dynamics 365 Commerce includes a large set of modules referred to as the Commerce module library. If you don't use some modules on your e-commerce site, exclude them to help reduce the JavaScript chunk size. The live e-commerce site doesn't render excluded modules. Commerce site builder doesn't make them available when you create pages.

Applies to

This article applies to the following configurations:

  • Version: Commerce 10.0.16 or later
  • Component: Business to consumer (B2C) or business to business (B2B)
  • Feature area: Commerce website performance

Prerequisites

Install the Dynamics 365 Commerce online software development kit (SDK). For more information, see Install the online SDK.

Steps to reduce JavaScript

To exclude unused modules, add the module names to the excludeModules property in the SDK's platform.settings.json file (/src/settings/platform.settings.json).

  1. Open a Windows Command Prompt window.

  2. Go to the /src/settings directory in your SDK installation location.

  3. Open the platform.settings.json file in a text editor.

  4. Insert the following code in JavaScript Object Notation (JSON) format. Replace <EXCLUDED_MODULE_NAME...> with the name of the module to exclude. Enclose each module name in double quotation marks. If you exclude multiple modules, separate the module names with commas.

    {
        "excludedModules": ["<EXCLUDED_MODULE_NAME1>","<EXCLUDED_MODULE_NAME2>"]
    }
    

Validate

Use one or both of the following methods to validate that a module was successfully excluded.

Method 1

  • Description or purpose: Verify that the module is excluded.
  • Steps to run: Compare the chunk size that appears after a build.
  • Passing result: The chunk size is smaller after a new build.

Method 2

  • Description or purpose: Verify that the module is excluded.

  • Steps to run: Test the module in a development environment by following these steps:

    1. Run the Node server by using the yarn start command.
    2. Visit the following URL: http://localhost:4000/modules?type=<YOUR-MODULE-NAME>.
  • Passing result: The excluded module doesn't render on the webpage.

Additional resources

Install the online SDK

Set up a development environment