I’m using Typeform. I’ve added the script within Embed Code and works fine. However I don’t want it displaying when using a mobile device. I selected Display None on the landscape and portrait Mobile but it still displays. Any ideas:
Hi Jeff. Thanks for your swift reply. I’m not too hot on coding. If I add `const mediaQuery = window.matchMedia(‘(min-width: 768px)’)
// Check if the media query is true
if (mediaQuery.matches) {
@flem1985 - Based on your topic title I was pointing you to a solution that would only load the Typeform embed script itself when the viewport size was greater than X. Hiding the embed with CSS display:none does not stop the script from loading in the browser.
You could use this example code, placed in your before body custom code area on the page and change the embed to remove the script typeform provided.
<script>
//cache the script in the browser if loaded
$.ajaxSetup({
cache: true
});
const mediaQuery = window.matchMedia("(min-width: 768px)");
if (mediaQuery.matches) {
$.getScript("https://embed.typeform.com/next/embed.js");
}
</script>
The embed code where you are placing the form would need to have the <script src="//embed.typeform.com/next/embed.js"></script> removed, leaving only the typeform provided DIV element.
If you need customization help you reach me with a DM and could buy some of my time as I am busy.