Enqueue script if screen is greater than 500

you can use Window matchMedia() Method https://www.w3schools.com/jsref/met_win_matchmedia.asp like this:

 <script type="text/javascript">
        if (matchMedia('only screen and (min-width: 500px)').matches) {

    }
    </script>