I would like to add a preload=“auto” attribute to my video component to let the browser know it’s top priority. How would I be able to achieve that using builder?
I tried using HTML Attributes but that one attaches those attributes to the div container, not the video component itself.
I tried too but it seems using HTML attributes, it adding the property to the parent div instead video element. So to workaround this you can use Custom JS, for example:-
let videos = document.getElementsByClassName('builder-video');
//Set attribute only to the first video in a page
videos[0].setAttribute("preload", "auto");
//or
//Set attribute to all videos in the page
for(let i=0; i < allVideos.length; i++){
videos[i].setAttribute("preload", "auto");
}
Thanks Garima for the quick feedback.
One of the reasons that I chose Builder was because I eventually want the best experience in building static landing pages. Eventually, if Builder is blocking me from executing what I need (I.E: preload=‘auto’ on videos), than I’d need to revert to building my pages with code and no one wants that.
In my opinion, Adding a new advanced setting for the video component that allows us to choose the wanted preload method should be very valuable (Also, I don’t work at Builder, but tech wise it seems like a very short task to build)
BTW: The same goes for the “lazy” property in your Image component. As far as I know, Builder decides it automatically adds it as lazy, but what if I don’t want it to be?
@RonHagafny, encourage you to submit a feature request (to add a toggle for lazy property for the image component too in advance settings same as in the video) here Builder.io Ideas.
As a workaround, you can open the JSON view of the image and set the lazy value as false if you don’t want it to be:-
I manually set lazy:false from JSON. I didn’t touch space-wise setting because it’s set to the recommended settings of only lazy loading images that are not above the fold. Hero image is above the fold
Attached are 2 images. One from builder and one from actual homepage.
@RonHagafny thank you for further details on this, I’ve tested this on my testing space and it seems bug from our end. I’ll check with the team for a fix and keep you posted!