Quick question about triggering a javascript chart...
# javascript
j
Quick question about triggering a javascript chart (amCharts in this case) after manually selecting a tab: I have added some tabs to a "detailed view" on a product listing. On one of the tabs, a chart is generated. As there are about 30 concurrent products listed, 30 charts are being drawn in the background before I know if the visitor actually wants to see the chart, which delays the entire page build too much. Is there a good way using AlpineJS ideally (which I use for the tabs) to trigger the javascript for the charts when the selected tab is active? Many thanks for pointers!
p
Would the intersect plugin work? I think I'd either set it up to lazy load using it, or change the tab code to trigger loading the remote content only when initially clicked... https://alpinejs.dev/plugins/intersect
j
Ah, cool idea - I'll test that! Cheers @Patrick S