Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

added fastLaneWhitelist option #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions comcastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ var comcastifyjs = (function () {
boxColor: args.boxColor || '#000000', // color of box overlay
loadMaxPercent: args.loadMaxPercent || 0.0, // max percentage to load images
loadSpeed: args.loadSpeed || 500, // how often in ms to pass
loadIncrement: args.loadIncrement || 1 // pixels to load per pass
loadIncrement: args.loadIncrement || 1, // pixels to load per pass
fastLaneWhitelist: args.fastLaneWhitelist || [], // domains to whitelist
};

// make 'em load slow
Expand All @@ -57,6 +58,11 @@ var comcastifyjs = (function () {
parent = img.parentNode,
slowload = document.createElement('DIV');

// whitelisted?
if (params.fastLaneWhitelist.indexOf((new URL(img.src)).hostname) !== -1) {
continue;
}

// set up initial state of box
slowload.style.backgroundColor = params.boxColor;
slowload.style.width = img.offsetWidth + 'px';
Expand Down Expand Up @@ -92,4 +98,4 @@ var comcastifyjs = (function () {
fixMyImagesLoadingSoFast: slowImages
};

})();
})();
9 changes: 7 additions & 2 deletions example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@
<img src="sloth.jpg" alt="http://www.wisegeek.com/what-are-the-main-components-of-a-sloth-diet.htm#sloth-in-tree-showing-claws" />
</div>

<div>
<img src="http://cdn.comcast.com/~/Media/2014/mobile/xfinity_c_lg.aspx" />
</div>

<script type="text/javascript" src="../comcastify.js"></script>
<script type="text/javascript">

window.onload = comcastifyjs.fixMyImagesLoadingSoFast({
boxColor: '#123456',
loadMaxPercent: 0.75,
loadSpeed: 100,
loadIncrement: 5
loadIncrement: 5,
fastLaneWhitelist: ['www.netflix.com', 'cdn.comcast.com', 'www.timewarnercable.com']
});

</script>

</body>

</html>
</html>