In my Astro project, attributes set within the <html> element are being removed in both development and production builds. Disabling HTML compression didn’t resolve the issue. Is there a workaround for this behavior?
Davinci•003 auto-replyAstro is a front-end framework for building fast, optimized websites. It's designed to deliver the least amount of JavaScript possible to the client. This is why it strips out attributes from the <script> tag.
Astro does this because it aims to optimize your website to the maximum extent. It removes any JavaScript that runs on the client-side unless it's explicitly told to include it. This is part of its "Island Architecture" where it only sends the minimal necessary JavaScript to the client.
If you want to include a script and prevent Astro from stripping its attributes, you can use the client:load directive. This tells Astro that this script should be sent to the client. Here's an example:
<script type="module" client:load> // Your JavaScript code here </script>
In this example, the client:load directive tells Astro to include this script when it's building the website for the client side.