I have about 5 tags loading images on the main page of the dope theme and I’m trying to optimize the site’s load time by lazyloading the off-screen images. It seems like the dope theme is using the owl carousel javascript to render the elements on the page but I’m not familiar enough with js and website development to understand the error I’m seeing.
Based on this documentation I should be able to add lazyLoad:true,
to the function in the assets/js/main.js
file and update the index.hbs
to include the class owl-lazy
and change the img src to data-src
. However when I make those changes and restart ghost, the site doesn’t load any images.
Any help would be appreciated, Thanks!
changes I made to main.js…
function tagFeed() {
'use strict';
var count = $('.tag-feed').attr('data-count');
$('.tag-feed').owlCarousel({
lazyLoad:true,
dots: false,
nav: true,
changes I made to index.hbs…
{{#foreach tags}}
<div class="tag u-placeholder">
<img class="tag-image u-object-fit owl-lazy" data-src="{{#if feature_image}}{{img_url feature_image}}{{else}}{{@site.cover_image}}{{/if}}" alt="{{name}}">