is there any way to load JS code/files on demand instead of compiling all my JS codes into one file and then serve to the user but most of the code might remain unused?

[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]
1 Comment

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer