Don't add noscript and change onload when already exists
See original GitHub issueWhen the input html contains a stylesheet which is already loaded async with the media strategy example:
<link rel="stylesheet" href="styles.40e2e5031a642e407437.css" media="print" onload="this.media='all'">
<noscript><link rel="stylesheet" href="styles.40e2e5031a642e407437.css"></noscript>
Critters will output an addition noscript tag and change the onload
of the original link file.
- <link rel="stylesheet" href="styles.40e2e5031a642e407437.css" media="print" onload="this.media='all'">
+ <link rel="stylesheet" href="styles.40e2e5031a642e407437.css" media="print" onload="this.media='print'">
+ <noscript><link rel="stylesheet" href="styles.40e2e5031a642e407437.css" media="print"></noscript>
<noscript><link rel="stylesheet" href="styles.40e2e5031a642e407437.css"></noscript>
In this case while critters should extract the critical css it should not add an addition noscript tag nor change the onload to print.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
If dynamically added script already exists, how to not add it ...
Whenever you want to add the script and regardless of what triggers it, determine the id of the script to add and check...
Read more >The Script element - HTML: HyperText Markup Language
This attribute indicates the type of script represented. The value of this attribute will be one of the following: Attribute is not set...
Read more >Integrate Google Tag Manager with Next.js - Morgan Feeney
Set up Google Tag Manager (GTM). To get up and running you'll need to add the tag manager script to the <head> of...
Read more >SCR19: Using an onchange event on a select element ... - W3C
This technique will not cause a change of context. ... to function properly</noscript> <h1>Dynamic Select Statements</h1> <label for="continent">Select ...
Read more >Three JavaScript articles and one best practice - QuirksMode
They discuss different aspects of the change JavaScript is going ... Since we add the <link> as soon as possible, and don't wait...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@alan-agius4 I think we could use this request as an interesting use-case for the plugin API @janicklas-ralph has been noodling on. It’s mainly aimed at additional HTML tree reduction, but it should be possible to have it also support marking nodes as “do not mutate”.
@developit, we are using
reduceInlineStyles:false
.The main reason for this is, so that between the transition from the SSR’d view to CSR view. Angular will remove/or re-use components
<styles>
generated on the server. However, when usingreduceInlineStyles
this is not possible because all styles are merged into a singlestyle
tag and causes metadata that is needed for styles to be be re-used to be lost, since this data is stored as attributed onstyle
tags.Overall, I am fine with closing this request. We did find a workaround to get around this.