0

I am looking to get the length of the entire document (as in str.length) and any other files the document may use. This question (How to get the entire document HTML as a string?) was helpful, but it only gives the characters in the current document not taking into account any linked js or css files. Any suggestions?

Community
  • 1
  • 1
www139
  • 105
  • 10

1 Answers1

0

This is entirely pseudocode, but it should help you. While it would be impossible to guarantee the accuracy of said length - due to the amount of variations in coding HTML, and how much depth there is with page-to-page linking.

This would also use Jquery.

var length = 0;

$(document).ready(function() {
   //do whatever you need to, to get the current document link (using link provided above)
   length = currentDocument.Length;

   //iterate through each LINK HREF
   //do the same for script and SRC
   $(document).find("link").each(function() {
        var attr = $(this).attr("href");

        //if this accesses a different server than your own, it prolly will fail

        if (attr != null)
        {
           $.ajax({
                url: attr,
                async: false,
                success: function (data){
                    length += data.length;
                }
            });
         }
   });
}
Jeffrey Kern
  • 2,024
  • 20
  • 40