elegantthemes / Divi-Beta

8 stars 0 forks source link

How to separate module related JS into multiple files and enqueue only required scripts #97

Open xxtesaxx opened 1 month ago

xxtesaxx commented 1 month ago

What is your documentation request?

I would like to know how/where/when I should enqueue a module related script file so that it is only loaded by the browser, when the module is used on a given page. This issue directly relates to the tutorial request in Discord: https://discord.com/channels/1041765492907589683/1295715322480820287

The basic idea is that instead of having one giant JS file like we have in D4 (which is always enqueued), we want to be able to separate module related scripts into:

Example: Imagine a simple module with a text field, 2 color fields and a number field. The module itself would render the text as HTML. An external JS file (placed somewhere in the project) would take the two colors and the number to alternate the text and background color with the number as the dealy between alternations.

What type of documentation would you like to see?

doesn't matter

What are the main points the documentation should cover?