and script is executing only on devices below 980px… but of course whole script code inside will be still loading on upper resolutions on page load, but will not execute instructions… If U dont want to load your script > 980 save code U want to run in file, then using JS create element script in footer with link to your file
Indeed the JavaScript code appears in the source code of the page, but with your instruction it is not executed. I have done some tests and it works fine.