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

Have the ability to add a name or id to a set of rules #298

Open
tunetheweb opened this issue Feb 8, 2024 · 1 comment
Open

Have the ability to add a name or id to a set of rules #298

tunetheweb opened this issue Feb 8, 2024 · 1 comment

Comments

@tunetheweb
Copy link

It would be nice to be able to optionally have a better rule set name to expose in things like DevTools. Currently Chrome just defaults to the name of the file the rules were found in. Which is less than ideal if adding multiple rules:

image

And maybe they should be able to be specified per rule group like my-rule-set-2 and my-rule-set-3 below? Though currently DevTools lists them in <script type="speculationrules"> so would be unable to show 2 and 3 on separate lines without changes to that.

<script id="speculationrules1" type="speculationrules">
    {
      "prerender": [{
        "id": "my-rule-set-1",
        "urls": ["apple.html", "orange.html"]
      }]
    }
</script>
<script id="speculationrules2" type="speculationrules">
    {
      "prefetch": [{
        "id": "my-rule-set-2",
        "urls": ["barry.html"]
      }],
      "prerender": [{
        "id": "my-rule-set-3",
        "urls": ["kiwi.html"]
      }]
    }
</script>

Alternatively, we could use the id (or name) attribute from the <script> tag instead and just make this a Chrome DevTools implementation change instead of a spec change. But that would definitely only allow one per script tag - which is probably fine.

@domenic
Copy link
Collaborator

domenic commented Feb 9, 2024

I think we should start with the id on the script tag as a Chrome DevTools implementation change. (Someone should do a quick mockup of how best to signal that---do we include the URL too? What typography do we use? Etc.)

But there is precedent for this kind of debugging-only property with worker names. So if we, or any other browser, ever has a UI which displays each rule set separately, we could easily add this. Similarly, if we add more introspection APIs in the future which would benefit from identifying the triggering rule set, we could add this.

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

No branches or pull requests

2 participants