Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subresource Integrity when using @import

Tags:

css

What is the syntax to include subresource integrity when using @import?

@import url(//use.fontawesome.com/releases/v5.3.1/css/all.css);

Besically how do I include the subresource integrity and crossorigin parameters when using @import like above?

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
like image 289
adam78 Avatar asked Oct 17 '22 13:10

adam78


1 Answers

TL;DR: SRI is a browser-thing, CSS at-rules (like @import) are a css-thing.

What is the syntax to include subresource integrity when using @import?

From what I can tell, there is nothing in the current CSS spec (CSS3 drafted as of writing this) - where usage of @import is defined - that details usage of SRI for css.

Besically how do I include the subresource integrity and crossorigin parameters when using @import like above?

Those parameters define how the browser fetches the resource and interprets its legitimacy. This happens before the resource is implemented (js, css, etc.).


External Resources:

  • CSS3 Spec draft (specific to at-rule usage): https://drafts.csswg.org/css-cascade-3/#at-ruledef-import
  • MDN page on @import usage: https://developer.mozilla.org/en-US/docs/Web/CSS/@import
  • MDN page detailing SRI: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
like image 84
William Bueti Avatar answered Oct 21 '22 05:10

William Bueti