When using external javascript files within components what is the best method to pass data to a javascript file? Assuming components can be used multiple times on a single page I can't really use static IDs to target a specific element.
I guess I can use something like this and in my javascript run a for loop(?) to pass settings and data but it feels kind of hacky.
<script>
window.components['{{ __SELF__.id }}'] = {
id: '{{ __SELF__.id }}',
foo: [
'{{ bar }}',
'{{ baz }}'
]
};
</script>
And actually I'm not entirely sure, do css/js files get injected once or for each component instance?