question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't add noscript and change onload when already exists

See original GitHub issue

When 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:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
developitcommented, May 27, 2021

@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”.

0reactions
alan-agius4commented, May 27, 2021

@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 using reduceInlineStyles this is not possible because all styles are merged into a single style tag and causes metadata that is needed for styles to be be re-used to be lost, since this data is stored as attributed on style tags.

Overall, I am fine with closing this request. We did find a workaround to get around this.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found