1

I have a css file in my <head> tag, defined as follows:

<link href="foo/bar/baz.css" rel="stylesheet" class="lazyload" type="text/css">

I want to be able to remove this css file dynamically, from the javascript. However, at runtime, I won't have the full href available, only the baz.css part (That's because the file is hosted at a CDN, and the url can be dynamically generated / different each time, so it can't be hard-coded).

The css file will always have the class lazyload.

How can I remove this?

7
  • Just curious, why remove it? Commented Mar 28, 2014 at 22:41
  • 1
    What do you mean, "remove"? Once the CSS has been loaded, the browser's not going to forget about it. (At least I don't think it will.) Commented Mar 28, 2014 at 22:42
  • Are there other elements with the lazyload class ? Commented Mar 28, 2014 at 22:42
  • 2
    @Pointy - That's correct, but it can be disabled though Commented Mar 28, 2014 at 22:44
  • 2
    @Pointy - searched and found -> stackoverflow.com/questions/3182840/… Commented Mar 28, 2014 at 22:47

1 Answer 1

5
$("link[href*='baz']").prop('disabled', true);
$("link[href*='baz']").remove();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.