How to install widget only for dektop website version

If you want to install the widget only for the desktop version of your website, you need to replace the platform script (the 1st line of the code) in your widget installation code with this script:

<script>
if (window.innerWidth > 440) {
  const elfPlatform = document.createElement("script");
  elfPlatform.src = "https://static.elfsight.com/platform/platform.js";
  elfPlatform.defer = true;
  elfPlatform.setAttribute('data-use-service-core', "");
  document.head.append(elfPlatform);
}
</script>

Here is an example of how the full installation code will look:
<script>
if (window.innerWidth > 440) {
  const elfPlatform = document.createElement("script");
  elfPlatform.src = "https://static.elfsight.com/platform/platform.js";
  elfPlatform.defer = true;
  elfPlatform.setAttribute('data-use-service-core', "");
  document.head.append(elfPlatform);
}
</script>
<div class="elfsight-app-46e572bc-ad98-4609-8ec7-3af76855bfd4" data-elfsight-app-lazy></div>

Got questions or faced issues? Describe your use case in the comments and we’ll be happy to help :slightly_smiling_face:

1 Like