Currently, when using Beasties to inline critical CSS, the generated <style> tag is created without any custom attributes. This creates a significant conflict with strict Content Security Policy (CSP) environments
I would like to see a new option in the Beasties configuration (e.g., styleAttributes) that accepts an object of key-value pairs. These attributes should be spread onto the injected <style> tag.
const beasties = new Beasties({
// ...other options
styleAttributes: {
nonce: 'rAnd0m123',
'data-type': 'critical-css',
id: 'beasties-inline-style'
}
});
Output
<style nonce="rAnd0m123" data-type="critical-css" id="beasties-inline-style">
/* Critical CSS content */
</style>
This way, we can add hashes if needed to the generated style tag