@jeroen I’m not expert on this new thing yet, but I would say:
- In JavaScript: create an input, set its type to checkbox and set the switch attribute, then test if `"switch" in inputˋ is true. The fact that the IDL property is set probably indicates support.
- in CSS: maybe a directory like ˋ input[type="checkbox"][switch][role="switch"]` would detect support, since the browser adds the switch role. But I’m not 100% sure.
The switch attribute was made to silently progressively enhance any checkbox. But you’re right that detecting support would avoid loading unnecessary code for those who already have custom switches.
@tomayac might be able to help further.