Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically swap out images/videos based on the user's OS #489

Open
TheJaredWilcurt opened this issue Mar 4, 2025 · 0 comments
Open

Dynamically swap out images/videos based on the user's OS #489

TheJaredWilcurt opened this issue Mar 4, 2025 · 0 comments

Comments

@TheJaredWilcurt
Copy link

I assumed this, like all the other "cool new browsers" from the past few years was an Apple exclusive because your are only showing screenshots that look to be running on OSX.

I've been making Cross-platform Desktop Apps for years and have always found that Windows users dominate downloads of desktop apps. Even for software development tools, it's still 70+%.

It's very important to make a good first impression and say "We care about you, and have taken the time to customize the website to cater to you, yes, our developers use your OS and manually test things there, you are not an after-thought". The website's goal is mostly just marketing and giving people the download link. Marketing works better when it's targeted.

You can use the UserAgent to make an educated guess as to what OS/Arch the user has and present that as the default link too. Obviously, you'd still have an "Other Downloads" or "More Downloads" button next to it.

UAParser().withClientHints().then((result) => {
  const CPU = result.cpu.architecture; // 'arm64', 'amd64', 'ia32', etc.
  const OS = result.os.name; // 'Windows', 'Ubuntu', 'Android', 'MacOS', etc
  if (OS === 'Windows') {
    // Show Windows screenshots/videos
    if (CPU === 'arm64') {
      // Show Windows arm download
    } else {
      // Show Windows 86/64 download
    }
  } else {
    // ...
  }
});

This does require you to create matching screenshots on each OS, but honestly if you aren't willing to do that, then I don't trust that you are actually manually testing this browser in those OS's anyways. So I also have to assume your app is a buggy mess on those platforms. Perception matters.

A trick I've used before is adding classes to the <html> tag and using CSS to show/hide elements based on the UA. Browsers skip downloading images until they are displayed.

<html class="linux ubuntu debian amd64 ubuntu22 firefox firefox135">
<img src="/static/images/hero-win.png" alt="MyApp on Windows" class="windows">
<img src="/static/images/hero-lin.png" alt="MyApp on Linux" class="linux">
<img src="/static/images/hero-lin.png" alt="MyApp on MacOS" class="macos">
img.windows,
img.linux,
img.macos {
  display: none;
}
html.windows .windows,
html.linux .linux,
html.macos .macos {
  dislay: inline-block;
}
<!-- Smart defaults for the download buttons -->
<a href="/downloads.html" class="btn" id="download-button">
  <img id="download-icon" src="/static/images/down-arrow.svg" aria-hidden>
  <span id="download-text>Download</span>
</a>
<a href="/downloads.html" class="btn">All Download Options</a>
// Some dummy vanilla JS to demonstrate changing the buttons after the UA is detected.
const downloadButton = document.getElementById('download-button');
const downloadIcon = document.getElementById('download-icon');
const downloadText = document.getElementById('download-text');
downloadButton.href = '/downloads/my-app-v1.0.0-' + OS + '-' + ARCH + '.' + fileExtension;
downloadIcon.src = '/static/images/os-logo-' + OS + '.svg';
downloadText.innerText = OS + ' Download';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant