#Bundle script with additional attribute

12 messages · Page 1 of 1 (latest)

wheat fern
#

Hey there, I would like to know if it's possible to bundle a script with an additional attribute ?

Example :

<script data-reload>
//my script
</script>

The default behaviour of astro is not to bundle such scripts however, I need the data-reload attribute.
Is there anyway to bundle the script anyway while also having the attribute ?

Thanks !

lethal lagoon
#

Would you expect the bundled script tag to get the attribute? What would happen if you added the same attribute with two different values? how would it decide which one to put on the bundled tag?

wheat fern
#

Yep, I'm expecting the bundled tag to get the attribute

wheat fern
#

I was just wondering if it was possible to override the default behaviour

#

Since I'm using flamethrower and this attribute is required to refresh the script on page change

#

And bundling it would be nice

lethal lagoon
#

Do you want flamethrower to rerun the full bundled JS on every transition? That’s seems like it defeats the point of flamethrower

wheat fern
#

Now that I think about it that's kind of dumb

#

I'll find an alternative then

long oyster
#

There's definitely a use case where you'd want the reload attribute. Like an island that only exists on one page. You'd need the reload attribute in order for the component's script to run when navigating to that page with flamethrower (unless you do is:inline, which is not ideal if you have multiple instances of that component).