I’ve used Stimulus for a while, but I’m new to Turbo, so apologies if this is a daft question.
My problem: I use vanilla-lazyload heavily (with placeholder and transition to loaded state) and I’m happy with it.
With Turbo, I of course have to tear down the changes before visit or disable previews so I don’t get a flash before the transition is rerun. I can live with this, but it got me thinking: why should it rerun the javascript on already loaded images (from previous visits)? They’re cached by the browser, so it’s not a big performance issue to run the javascript again. But vanilla-lazyload sets a class and a data attribute on images on load, and ideally I would like to keep these dom changes (client side only) across page changes so I don’t run unnecessary javascript.
Is there a way to do this? I know there’s a data-turbo-permanent
magic attribute, but all the examples are for video players and shopping carts. Would it make sense to use it for such a simple task as lazyloading images?
Thanks!