Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

434
Visualizações
Import CSS file into Javascript file or link to HTML file?

I just joined a project and noticed that the stylesheet is imported into each page's JS file as such:

import "../../style.css";

Now, I'm used to seeing CSS stylesheets linked in HTML files as follows:

<head>
  <link rel="stylesheet" href="styles.css">
</head>

The project is using Javascript/jQuery and Vite.js as an alternative to Webpack. I looked at the Vite documentation and saw that the example projects use the CSS @import, but there's no information on why that is in particular.

Is there any reason to import the stylesheet into JS files, rather than linking to the HTML files? Or vice versa? Not looking for opinions here, I'm wondering if there are best practices or advantages/disadvantages to consider with one approach or another.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It hands off the decision about when to include different bits of CSS to the bundler (e.g. webpack) instead of including every bit of CSS everywhere.

Further reading: Tree shaking CSS Modules

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda