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.

CSS/Stylesheet Injected Twice Into Head

See original GitHub issue

Hey, thanks for the great Plugin! I had a hard time with webpack & setting up dynamic imports. This is just working out of the box.

I’m having an issue with Stylesheets, which maybe related to vite, not this plugin, but to be sure I also post here. I already replied to the existing issue on vite.

I’m building a page with preact-client-routing example as startpoint. The issue with multiple injected styles exists inside this untouched repo. Just clone and try.

I’m using the newest version of the example.

If running npm run dev the import './PageShell.css' inside PageShell.jsx is injected as stylesheet and additionally as <style /> tag in the head. You also see the styles always two times inside the styles inspector.

2022-02-14_15h38_14

If running npm run build and npm run server:prod it is injected twice as stylesheet, here _default.page.client.jsx.2942c7fb.css.

2022-02-14_15h39_07

It would be great if this is fixed soon or eventually clarify if this is a vite issue. Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Feb 17, 2022

Had a look and it’s necessary to avoid CSS flashing. See comments in the commit.

Thanks for the digging.

1reaction
brilloutcommented, Feb 16, 2022

Good catch, will have a look at it tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Injected Twice Into Head · Issue #290 · dataarts/dat.gui
It looks like the same CSS is being injected into the head of the page twice ... var styleSheet = ___$insertStyle( ".dg ul{list-style:none ......
Read more >
Webpack imports the same styles multiple times - css
Since CSS assets are compiled statically, each stylesheet importing global has a copy in it. You could use Less, and the @import (reference) ......
Read more >
Precedence in CSS (When Order of CSS Matters)
loadCSS injects the stylesheet at the bottom of the <head> by default, so it would become #3 and the <style> block at the...
Read more >
Preload critical assets to improve loading speed - web.dev
In this example, Pacifico font is preloaded, so the download happens in parallel with the stylesheet. The critical request chain represents the ...
Read more >
CSS stylesheet in ascx file - MSDN - Microsoft
"CSS stylesheet in ASCX file". How can I inject CSS "on fly" in ASCX? I think it should be possible using Init method....
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