Use the script for third party javascript #8
-
Hi Mircea, I want to use the same logic to load script based on user interaction for third-party javascript and other javascript files that are available in /assets folder. How can I achieve that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@Ghaleb-alnakhlani It would be a good feature to have.
|
Beta Was this translation helpful? Give feedback.
@Ghaleb-alnakhlani It would be a good feature to have.
You can create your own custom loading logic by using some of the section code:
https://github.com/mirceapiturca/Sections/blob/master/App%20Optimization/app-optimization.liquid#L122
node.addEventListener(interactionEvent.event, eventFn, eventOptions);
Node is the DOM element mathed by the assigned CSS selectors.
interactionEvent.event is the assigned event.
eventFn is the function that loads the secipt, see:
loadScript(src)