For those who are already combining, compressing, and obfuscating their code but do not want all files to be loaded on every page due to a large bundle, there is a solution like the Commons Chunk Plugin provided by Webpack.
This handy plugin analyzes the dependencies for each page specified in your Webpack.config file and identifies which modules are needed across all pages. It then splits the code into two bundles: a "common" bundle containing modules required by every page, which must be included with a script tag on all pages:
<script src="commons.js" charset="utf-8"></script>
Additionally, it creates an individual endpoint bundle for each specific page that can be referenced in a script tag placed after the commons script tag:
<script src="specificpage.bundle.js" charset="utf-8"></script>
As a result, a single page will not have to load modules that are only utilized on other pages.
It should be noted that this functionality is specific to Webpack and may not be available as a Gulp plugin, as the plugin needs to understand all endpoints to determine common dependencies.