Considering your previous question regarding video streaming, it seems that you have a preference for NOT using the Adobe Dynamic Media, even though it could potentially be an effective solution.
Hence, If I understand your requirement correctly, both videos are currently loading on the initial page load and then being hidden based on conditions using CSS. You can optimize it as follows:
Update your HTML to initially hide both videos:
<video class="desktop-video test-123" style="display: none">
<source type="video/mp4"
src="${properties.videoURLForDesktop @ context='unsafe'}" >
</video>
<video class="mobile-video test-456" style="display: none">
<source type="video/mp4"
src="${properties.videoURLForMobile @ context='unsafe'}">
</video>
Then, show the respective video based on the viewport size using CSS media queries:
/* Display the desktop video on screens wider than 768px (adjust as needed) */
@590883 screen and (min-width: 769px) {
.desktop-video {
display: block !important;
}
}
/* Display the mobile video on screens 768px and narrower */
@590883 screen and (max-width: 768px) {
.mobile-video {
display: block !important;
}
}
With this approach, both videos are initially hidden with inline CSS, and then you use CSS media queries to selectively display the appropriate video based on the viewport size.