Yoona Yoona - 24 days ago 16
HTML Question

How to print link tag

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.

jQuery(document).ready(function($){
$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

You could simply do this :)

HTML

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

JQuery

  $(document).ready(function($){
      $('link').each(function(i, obj) {
        $(this).attr('href', ''); //replaces 'href' value to empty string
        $('.test').append($(this));
        alert($(this));
      });
  });
Comments