GoogleChrome / dialog-polyfill

Polyfill for the HTML dialog element
BSD 3-Clause "New" or "Revised" License
2.45k stars 245 forks source link

Attach css within the script #219

Closed nuxodin closed 3 years ago

nuxodin commented 3 years ago

What would be the disadvantage of appending the css inside the script to the document? It would be a much simpler approach and I don't see any disadvantages, plus a request would be saved.

I mean something like:

var css =
'dialog { \
  position: absolute; \
  ... \
';
var sEl = document.createElement('style');
sEl.appendChild(document.createTextNode(css));
document.head.append(sEl);
StephanBijzitter commented 3 years ago

This would be a pain in the ass when you have a Content Security Policy set up

samthor commented 3 years ago

Yes, please include the CSS in whatever way suits your site best.