Using jQuery I can get easily the number of DOM elemetns used by a web page:
$(\'*\').length;
But not all web sites are using jQuery.
The main answer doesn't really count everything (I think shadow DOM would be excluded)
Using snippet below works better for me:
$$('*').length