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:
one script file per module, e.g. each complex module gets its own script file
one script file for multiple modules, e.g. a script containing a common feature like lightbox for images, which is used across multiple modules (should probably work the same as the above, just wanted to mention it)
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?
Where to place external, module related script files
Where/when to enqueue the module related script file
How to pass modules attribute data to the JS file (e.g. via data-attributes on one of the modules html elements)
How to use the same script file on the frontend, the frontend builder and the backend builder
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?