MCPcopy Index your code
hub / github.com/zeman/perfmap / findImages

Function findImages

perfmap.js:5–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3var gWinWidth = window.innerWidth || document.documentElement.clientWidth;
4
5function findImages() {
6 var aElems = document.getElementsByTagName('*');
7 var re = /url\(("?http.*"?)\)/ig;
8 for ( var i=0, len = aElems.length; i < len; i++ ) {
9 var elem = aElems[i];
10 var style = window.getComputedStyle(elem);
11 var url = elem.src || elem.href;
12 var hasImage = 0;
13 var fixed = 0;
14 var body = 0;
15 re.lastIndex = 0; // reset state of regex so we catch repeating spritesheet elements
16 if(elem.tagName == 'IMG') {
17 hasImage = 1;
18 }
19 if(style['backgroundImage']) {
20 var backgroundImage = style['backgroundImage'];
21 var matches = re.exec(style['backgroundImage']);
22 if (matches && matches.length > 1){
23 url = backgroundImage.substring(4);
24 url = url.substring(0, url.length - 1);
25 url = url.replace(/"/, "");
26 url = url.replace(/"/, "");
27 hasImage = 1;
28 if(elem.tagName == 'BODY'){
29 body = 1;
30 }
31 }
32 }
33 if(style['visibility'] == "hidden") {
34 hasImage = 0;
35 }
36 if(hasImage == 1){
37 if ( url ) {
38 var entry = performance.getEntriesByName(url)[0];
39 if ( entry ) {
40 var position = getPositionOfMarker(elem);
41 var xy = getCumulativeOffset(elem, url);
42 var wh = elem.getBoundingClientRect();
43 var width = wh.width;
44 var height = wh.height;
45 if(width > 10){
46 if(height > 10){
47 placeMarker(xy, width, height, position, entry, body, url);
48 }
49 }
50 }
51 }
52 }
53 }
54}
55function getPositionOfMarker(element) {
56 var parentElem = element.parentElement;
57 while (parentElem) {

Callers 1

perfmap.jsFile · 0.85

Calls 3

getPositionOfMarkerFunction · 0.85
getCumulativeOffsetFunction · 0.85
placeMarkerFunction · 0.85

Tested by

no test coverage detected