JavaScript Is it possible to disable scripts depending upon media queries in CSS?

I'm really wondering if this is possible.

Right now I'm designing a new personal website for myself with HTML5/CSS3, and I found some nice javascripts to execute on my site such as snowing effects and so forth. They work perfect on big size screens like my laptop, but on my mobile phone, they just go crazy.

I've been using media queries to make my website responsive and I thought like maybe I could stop these scripts from working on small sized screens with some sort of 'disable code' or something in media queries. I'm not obsessed with these scripts of course, but some of them are really nice and useful and I'd be really glad if I could sort this problem out without losing them.

By the way, I'm also using Bootstrap so I need javascript running, so turning all the scripts off would be impossible for me. I just need to disable some specific ones.

I'd really appreciate your helps. Thank you all!

Answer:1

In your Javascript you can do it with something like this:

if (screen.width < 600) {
        // don’t download complicated script
        // use low-source images instead of full-source ones
}

else{
   //let's see the snowflakes()!
}
Answer:2

If you are set on depending on Media Queries, there is a javascript library you can use, enquire.js. Example from website

enquire.register("screen and (min-width: 40em)", {
    match : function() {
        // Load sidebar content in via AJAX.
        // Show sidebar
    },  
    unmatch : function() {
        // Hide the sidebar
    }
});
Answer:3

How can I change the background/highlight color of the column group in the following fiddle to another color than the light blue that shows by default? I have tried using plotOptions in various ways ...

How can I change the background/highlight color of the column group in the following fiddle to another color than the light blue that shows by default? I have tried using plotOptions in various ways ...

  1. highcharts change highlight color
  2. highcharts change selection color

Hello this is my code i am trying to prevent form submit when button is clicked, and load ajax. but form continue to submits, I tried to add preventDefault, and onsubmit false parametar but no luck. ...

Hello this is my code i am trying to prevent form submit when button is clicked, and load ajax. but form continue to submits, I tried to add preventDefault, and onsubmit false parametar but no luck. ...

I am new to Javascript and I would really appreciate your help . I am coding Hangman using JavaScript, Html, Css. I was able to genrate random Word ans also create placeholders based on the length. ...

I am new to Javascript and I would really appreciate your help . I am coding Hangman using JavaScript, Html, Css. I was able to genrate random Word ans also create placeholders based on the length. ...

  1. calling javascript function from html
  2. calling javascript function from php
  3. calling javascript function from c#
  4. calling javascript function from razor view
  5. calling javascript function from cshtml
  6. calling javascript function on form submit
  7. calling javascript function from html onclick
  8. calling javascript function from java
  9. calling javascript function from another js file
  10. calling javascript function on page load
  11. calling javascript function with parameters
  12. calling javascript function in jquery
  13. calling javascript function from python
  14. calling javascript function from jsp
  15. calling javascript function from another function
  16. calling javascript function from code behind
  17. calling javascript function from link button in asp.net
  18. calling javascript function from another file
  19. calling javascript function in react component
  20. calling javascript function in div tag

so my domain name is going to change from building it on my computer (localhost) to what my domain name will be when i actually deploy it, and I don't want to go back and have to change it in a ...

so my domain name is going to change from building it on my computer (localhost) to what my domain name will be when i actually deploy it, and I don't want to go back and have to change it in a ...

  1. html javascript global variable
  2. html javascript global var
  3. html javascript global function
  4. html javascript global array
  5. html javascript set global variable
  6. javascript html declare global variable
  7. javascript global html