lazy load

This commit is contained in:
Kyle
2020-04-23 12:07:54 -07:00
parent c5fc8182f9
commit 58d7314165
10 changed files with 19 additions and 2 deletions

View File

@@ -1,5 +1,21 @@
lazyLoad([[], [], [], [], [], [], [], []])
lazyLoad([
['data/site/images/samples/fullRes/sample1.png', 'sample1'],
['data/site/images/samples/fullRes/sample2.png', 'sample2'],
['data/site/images/samples/fullRes/sample3.png', 'sample3'],
['data/site/images/samples/fullRes/sample4.png', 'sample4'],
['data/site/images/samples/fullRes/sample5.png', 'sample5'],
['data/site/images/samples/fullRes/sampleBling.png', 'sampleBling'],
['data/site/images/samples/fullRes/sampleCustomize.png', 'sampleCustomize'],
['data/site/images/samples/fullRes/sampleVariety.png', 'sampleVariety']
])
function lazyLoad(imageList = []) {
for (var i = 0; i < imageList.length; i++) {
var tempSampleImage = new Image()
tempSampleImage.customVarId = imageList[i][1]
tempSampleImage.onload = function() {
document.getElementById(this.customVarId).src = this.src
}
tempSampleImage.src = imageList[i][0]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -269,6 +269,7 @@
<script defer src="data/scripts/sortable.js"></script>
<script defer src="data/scripts/main.js"></script>
<script defer src="data/scripts/versions/m15/version.js"></script>
<script defer src="data/scripts/lazyLoadSamples.js"></script>
<!-- <script async src="data/scripts/palettes/darkMode.js"></script> -->
</body>
<footer class='footer'>