I developed a quiz module for a client and it has 6 outcomes. Each outcome has either a meeting link scheduler or form embedded. The quiz works great but when looking at the page performance Google shows duplicate javascript file bundles loading on the page. So each form or scheduler embed is the issue. I’ve try to set this up several different ways but I still have not found a solution so I don’t have the same js file loading multiple times. I’m not sure why Hubspot is loading it’s own files in multiple times. I’ve loaded multiple forms on a page before and have not had this issue.
To remove duplicate modules in JavaScript bundles, you can use a module bundler like Webpack and its built-in feature called “optimization . splitChunks”. This feature splits the bundles into smaller chunks and removes duplicate modules. Here are the steps:
Install Webpack and its dependencies.
Configure Webpack to use “optimization.splitChunks” in your configuration file.
Set the “chunks” option to “all” in the splitChunks configuration to ensure that all duplicate modules are removed.
Run Webpack to generate the optimized bundle with no duplicate modules.
Alternatively, you can use other module bundlers or plugins such as Rollup.js or Babel-plugin-duplicate-imports-elimination to achieve similar results.