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

unused data-astro-image styles #12868

Open
1 task
phelix3948 opened this issue Dec 31, 2024 · 2 comments
Open
1 task

unused data-astro-image styles #12868

phelix3948 opened this issue Dec 31, 2024 · 2 comments
Labels
needs repro Issue needs a reproduction

Comments

@phelix3948
Copy link

phelix3948 commented Dec 31, 2024

Astro Info

Astro                    v5.1.1
Node                     v20.18.1
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/tailwind
                         astro-icon
                         @astrojs/sitemap

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

No response

Describe the Bug

I see it generates some data-astro-image styles that are not used by me.

Screenshot from 2024-12-31 19-49-04

i just use <img tags to link images from public folder.
but how to disable these unused styles inserted on top of each page?
I've tried this, but it won't work:

astro config:

experimental: {
    responsiveImages: false
  },

What's the expected result?

no data-astro-image styes inserted anywhere, because I am not using any <Image, <Picture. I just use <img

Link to Minimal Reproducible Example

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 Dec 31, 2024
@florian-lefebvre florian-lefebvre added the needs repro Issue needs a reproduction label Jan 1, 2025
Copy link
Contributor

github-actions bot commented Jan 1, 2025

Hello @phelix3948. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jan 1, 2025
@my-astro
Copy link

my-astro commented Jan 2, 2025

I was going to create the same issue.

So:

Netlify adapter creates two duplicate inline <style> tags OP listed. This style might be called either generic.CVYE6UPY.css or image.CVYE6UPY.css (I’ve noticed that it is called image... in my current project and generic… in the demo for reproduction. Sadly I can not create a repro cause my project has too many integrations to isolate the problem.

The problem with those styles is that Astro can add multiple instances of the same <style> tag and if you have configured inlineStylesheets: “never” , one of the <style> tags will ignore it. That leads to being open to XSS-attacks and also mess up my strict CSP rule (cause by default CSP blocks all inline styling.

I’ve tested it with Cloudflare adapter and no styles were created.

How the code looks on almost empty project:

  width: 100%;
  height: auto;
  object-fit: var(--fit);
  object-position: var(--pos);
  aspect-ratio: var(--w) / var(--h);
}
[data-astro-image="responsive"] {
  max-width: calc(var(--w) * 1px);
  max-height: calc(var(--h) * 1px);
}
[data-astro-image="fixed"] {
  width: calc(var(--w) * 1px);
  height: calc(var(--h) * 1px);
}

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

No branches or pull requests

3 participants