Your generous donation allows me to continue developing and updating my code!
From the jQuery .load() API docs:
jQuery uses the browser's .innerHTML property to parse the retrieved document and insert it into the current document. During this process, browsers often filter elements from the document such as html, head, or body elements. As a result, the elements retrieved by .load() may not be exactly the same as if the document were retrieved directly by the browser.
The code
$(function(){ var body = $('body'), pages = 'all no-body no-head no-html'.split(' '), selectors = 'html #html_foo .html_bar head #head_foo .head_bar body #body_foo .body_bar'.split(' '); (function fetch() { if ( !pages.length ) { return; } var page = pages.shift(); $.get( 'test-' + page + '.html', function(html){ debug.log( '=== ' + page + ' ==='); var hd = $.htmlDoc( html ); debug.log( '$.htmlDoc( html )', hd.length ); $.each( selectors, function(i,selector){ var find = hd.find( selector ); find.length && debug.log( '.find("' + selector + '")', find.length ); var filter = hd.filter( selector ); filter.length && debug.log( '.filter("' + selector + '")', filter.length ); }); fetch(); }); })(); });