sveltejs / sveltejs/kit

Ability to specify link media attribute

Open
#3,097 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

For accessibility and performance it would be good to have a way to specify the media attribute for the generated CSS.
I mean that all the

<link rel="stylesheet" href="_app/index.012930190.css">

could be actually something like

<link rel="stylesheet" href="_app/index.012930190.css" media="screen">

thus many screen or braille readers, etc., could avoid downloading the stylesheets.

Describe the proposed solution

I'm not sure what a good a good solution would be but I guess I would prefer having a default media="screen" if nothing specified and maybe the ability in sfc files to do something like:

<style media="screen"> <!-- or print etc. -->
</style>
Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how generated CSS link elements are produced and how SFC style attributes are represented; the issue names no files or tests. Confirm the intended default and configuration behavior, then verify that generated stylesheet links can carry the requested media value without affecting existing output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility, frontend, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.