Skip to content

Instantly share code, notes, and snippets.

@simevidas
Created March 31, 2023 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simevidas/75cbb98b85cfa0520e6d6d2ed448194d to your computer and use it in GitHub Desktop.
Save simevidas/75cbb98b85cfa0520e6d6d2ed448194d to your computer and use it in GitHub Desktop.
9.1. Scripting Support: the scripting feature
Name: scripting
For: @media
Value: none | initial-only | enabled
Type: discrete
The scripting media feature is used to query whether scripting languages, such as JavaScript, are supported on the current document.
enabled
Indicates that the user agent supports scripting of the page, and that scripting in the current document is enabled for the lifetime of the document.
initial-only
Indicates that the user agent supports scripting of the page, and that scripting in the current document is enabled during the initial page load, but is not supported afterwards. Examples are printed pages, or pre-rendering network proxies that render a page on a server and send a nearly-static version of the page to the user.
Should there be an explicit minimum threshold to meet before a UA is allowed to claim initial-only? Having one would mean authors would know what they can depend on, and could tailor their scripts accordingly. On the other hand, pinpointing that threshold is difficult: if it is set too low, the scripting facilities that authors can depend on may be to constrained to be practical, even though actual UAs may potentially all support significantly more. But trying to set it higher may cause us to exclude UAs that do support scripting at loading time, but restrict it in some cases based on complex heuristics. For instance, conservative definitions likely include at least running all inline scripts and firing the DOMContentLoaded event. But it does not seem useful for authors to constrain themselves to this if most (or maybe all) initial-only UAs also load external scripts (including async and defer) and fire the load event. On the other hand, requiring external scripts to be loaded and the load event to be fired could exclude UAs like Opera mini, which typically do run them, but may decide not to based on timeouts and other heuristics. [Issue #503]
none
Indicates that the user agent will not run scripts for this document; either it doesn’t support a scripting language, or the support isn’t active for the current document.
Some user agents have the ability to turn off scripting support on a per script basis or per domain basis, allowing some, but not all, scripts to run in a particular document. The scripting media feature does not allow fine grained detection of which script is allowed to run. In this scenario, the value of the scripting media feature should be enabled or initial-only if scripts originating on the same domain as the document are allowed to run, and none otherwise.
Note: A future level of CSS may extend this media feature to allow fine-grained detection of which script is allowed to run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment