Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to prevent script tags from running on the server side #10953

Closed
1 task
danielo515 opened this issue May 5, 2024 · 2 comments
Closed
1 task
Labels
needs response Issue needs response from OP

Comments

@danielo515
Copy link

Astro Info

Astro                    v4.4.6
Node                     v18.18.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/tailwind
                         @astrojs/svelte
                         @sentry/astro
                         astrojs-service-worker

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

The code inside <script> tags is always executed. This mean, they are executed in the client, but also in the server.
While I understand this is something useful in case the server dom needs to be modified, it will be nice to have a way to be able to opt-out for some script tags.
Components do not exhibit the same behavior, where you can decide if they run on the client or the server and the client.

What's the expected result?

I want to be able to exclude some script tags to run while SSR without having to check for the SSR env variable.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-a7qbew?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label May 5, 2024
@Princesseuh
Copy link
Member

Script tags don't run on the server, what do you mean more precisely? Your repro even show this, as the console log doesn't appear in the terminal.

@Princesseuh Princesseuh added needs response Issue needs response from OP and removed needs triage Issue needs to be triaged labels May 5, 2024
@matthewp
Copy link
Contributor

Closing, please file a new issue if you can reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs response Issue needs response from OP
Projects
None yet
Development

No branches or pull requests

3 participants