Code
Remove duplicate modules in JavaScript bundles
Removing duplicate modules in bundles is one JavaScript optimization you can consider.
Despite JavaScript frameworks providing web developers with pre-defined bundles or packages, they can end up causing performance issues.
For example, duplicate or similar JavaScript code may find its way into your modules during development or within WordPress plugins. Adding JavaScript to a page increases the time required for the browser to process it, increasing processing time.
Why it is important
Nobody likes waiting. Over 50% of users abandon a website if it takes longer than 3 seconds to load.
Sending large JavaScript payloads impacts the speed of your site significantly.
Duplicate Javascript is useless but adds more weight to a page. The result is longer waiting times for customers and worse user experiences.
How the audit works
Sitefig evaluates all JavaScript modules on your page and flags duplicated modules across JavaScript bundles and their wasted bandwidth (KB).
Fixing the problem
Duplicated modules occur in several different ways:
-
Same code from the same package
This happens when the same code is present in different files from the same package. -
Similar code from similar packages
This happens when packages have similar code due to highly similar JavaScript functionality. -
Same code from the different package
This happens when the same code is present in files from different packages.