[ad_1]
Hi
I’m building a basic custom theme and I’m using Webpac to bundle all my JS files and code into one script file and then enqueue it. However, some of the code might never be used by the user (modals, toasters, etc).
Is there any way to improve this and instead of serving one main file, break it into separate files and let WP load them based on whether they are needed or not?
Thanks
[ad_2]
You can wp_enqueue js files conditionally.