Can I determine the number of jQuery objects on a page?
I want to use the number of elements as a kind of weak criterion for page complexity. I think that if I can reduce the number of elements jQuery knows about, the page can work more efficiently.
Is it as simple as making * selecting and counting results?
Related:How can I clear the content without waiting for fear, "stop working with this script?" dialogue?
http://api.jquery.com/size/
var elementCount = $('*').size();
Although this may be more than what you want:
var elementCount = $('body').find('*').size()
var n= 0; for (var i in jQuery.cache) n++;
n , jQuery "" ( , , ).
n
, , . jQuery 1.4.
, , innerHTML= '', , jQuery . , " ", , , jQuery.cache .
innerHTML= ''
jQuery.cache
live()/delegate() , . , , , , .
live()
delegate()
( ; , querySelectorAll, Selectors-API 2).
querySelectorAll
var elementCount = $('*').length;
jQuery, , .
Source: https://habr.com/ru/post/1747429/More articles:What does a basic C code dump mean? - cHelp with a simple query - why not using an index? - sql-serverHow can I clear the content without fear, "stop working with this script?" dialogue? - javascriptКак выполнять пакетные загрузки в SQL Server? - mergeIs it possible to list the number of lines? - c #How to convert a DATETIME value to a FILETIME value in T-SQL? - datetimeHow to count ls output in unix? - unixWord 2007 documents in Visual Studio 2010 - c #Sessional attacks, what are the new breeds of attacks? - securityjQuery plugin check hide / show error container - jqueryAll Articles