F
F
fu11buster2018-11-06 05:31:37
JavaScript
fu11buster, 2018-11-06 05:31:37

How to disable script loading for mobile devices?

I want to disable the loading of the Yandex.maps script on mobile devices, because the map does not appear on them. I tried to write in the HTML file like this:

<script type="text/javascript">
    if (document.body.clientWidth > 640) {
      document.write ('<script src="https://api-maps.yandex.ru/2.1/?apikey=[тут мой API key]&lang=ru_RU" type="text/javascript"></sc' + 'ript>');
    }
  </script>

Gives 2 warnings and an error:
5be0fcd94c459992559915.jpeg
How to properly disable script loading?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-11-06
@sergey_st

You can use the current device library

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question