Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Remove file that contains specific string in href via JS

In HubSpot a file called layout.min.css is automatically added and is you cannot disable this css file anywhere in the CMS.

As such, I've tried to remove() and disable the file via JS, but the styles from that css file are still being rendered.

When I view source, this file looks like this:

<link rel="stylesheet" href="//cdn2.hubspot.net/hub/xxxxxx/hub_generated/template_assets/1642616240355/hubspot/hubspot_default/shared/responsive/layout.min.css">

Now, notice the 1642616240355 in the URL? That number (for some reason) changes everyday.

Yesterday, I had the following running, and it removed the file:

$("link[href='//cdn2.hubspot.net/hub/xxxxxx/hub_generated/template_assets/1642528871696/hubspot/hubspot_default/shared/responsive/layout.min.css']").attr('disabled', 'disabled');
$("link[href='//cdn2.hubspot.net/hub/xxxxxx/hub_generated/template_assets/1642528871696/hubspot/hubspot_default/shared/responsive/layout.min.css']").remove();

However, as it keeps changing, I'm now looking to remove and disable any css file that contains layout.min.css in its href.

I'm aware that there's a :contains selector, which might be of use here, but unsure on how that would be implemented? As in, how would I tell the code to look at all stylesheets and remove the one that contains "layout.min.css" in its href?

Have also tried:

<script>
  const stylesheets = document.querySelectorAll('link[rel=stylesheet]');
  for (var i = 0; i < stylesheets.length; i++) {
    if(stylesheets[i].href.indexOf("responsive/layout.min.css") >= 0) {
      stylesheets[i].disabled = true;
      stylesheets[i].remove();
    }
  }
</script>

But it still shows the layout.min.css when viewing source.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I would recommend you to do this with pure JavaScript instead of JQuery. Because otherwise you have to wait until the JQuery library is loaded.

Use this code for that:

const cssElement = document.querySelector("link[href*='layout.min.css']");

cssElement.disabled = true;
cssElement.remove();
about 4 years ago · Juan Pablo Isaza Denunciar

0

Based on the code you provided that you said works, why not use the ends-with matcher: $=?

$("link[href$='layout.min.css']").remove();

That'll find all the <link> HREFs that end with 'layout.min.css' and remove them, which is exactly what you're describing as your goal.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda