T
T
Think With Your Head2015-09-22 22:26:51
JavaScript
Think With Your Head, 2015-09-22 22:26:51

Is it possible to detect downloadable resources using javascript?

Всем привет!

Допустим с помощью jquery количество картинок, загруженных в DOM делается на раз два:
var num = $('img').length;

А каждое событие загрузки картинки в браузер может быть отловлено:
$('img').on('load', function() { ... });

1) А как быть с background images? Можно ли их так ловко посчитать/отловить?
2) Как можно сделать тоже самое с css/js/font файлами и прочими загружаемыми ресурсами? То есть подсчитать их количество и отлавливать событие их загрузки в браузер.

Спасибо!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-09-23
Protko @Fesor

No, at least with certain reservations it is possible (styles and js are loaded using JS, then we can parse css and track how much we have loaded and how much more needs to be loaded).
Perhaps there is something in the browser API contest for extensions, but you can’t do it normally using the DOM API.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question