Yoona Yoona - 1 year ago 93
HTML Question

How to remove link tag

Update: Hi, I can call an id of the link css that are included on head of my site, and use remove() or empty href onload function to remove it, and the effects actually are removed but somehow google page insight still shows that css, here is my code, is there away to remove it before it was added to my site by plugin?

jQuery(window).load(function () {
jQuery('#font-css').attr('href', ''); or

Hi because I need to check all current css that are included in my site (wordpress), and delete it hopefully to combine and include it again in footer (for removing render block in google page speed test).
First, I want to print it to check what is that css. (it maybe from many themes and plugins, I can not find it manually).

This is my jquery to print it but it does not show anything, Please help me.

$string = '';
jQuery('head link').each(function(i, obj) {
$string += jQuery(this).html() + ' ';
alert('' + $string);

I want to see something like this :

<link rel="stylesheet" type="text/css" href="mystyle.css">
<link rel="stylesheet" type="text/css" href="mystyle1.css"> (if I found this one I want to remove it or at least check href to know where it is, please help me if you know how to do it).

Answer Source

You could simply do this :)


<p class="test"></p>


      $('link').each(function(i, obj) {
        $(this).attr('href', ''); //replaces 'href' value to empty string
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download