How to ignore javascript at low resolutions?

My dev site uses a lot of Skrollr animations with a resolution of 1024 pixels and higher. Under 1024px, I don’t want the animation to be displayed, so I hid all the images and something else.

However, the javascript that is called to create the animation still causes lower permissions and causes some problems.

Is there a way to basically say: “If the resolution is less than 1024 pixels, ignore these JS files?”

I tried putting them in a DIV and using my existing multimedia CSS queries to display a "display: none" DIV in lower resolutions, but this does not work.

FYI, these are files that are called:

<script type="text/javascript" src="/js/skrollr.min.js"></script>
<script type="text/javascript" src="/js/homepageanimation.js"></script>
+4
source share
5

jQuery(function($) { http://workwave.joomlatest01.mms-dev.com//js/homepageanimation.js -

jQuery(function($) {
    if(screen.width < 1024) {
        return;
    }
    // skrollr stuff....
}

skrollr 1024 .

+2

- jQuery..

$(window).width();

Javascript:

var w = window.innerWidth;
var ow = window.outerWidth; //toolbars and status, etc...

if(w > 1024) {
   //Skrollr
}

if, Skrollr

+2

script. script , 1024.

if(window.innerWidth >= 1024){
    var file = document.createElement('script')
    file.setAttribute("type","text/javascript")
    file.setAttribute("src", "/js/skrollr.min.js")
}
+1

, Skrollr . Google , Skrollr .init(), . , JS , - , :

JS /, , , .

$(document).ready(function() {
 if ($(window).width() > 1023) {
  skrollr.init();
 }
});

jQuery , .

0

( CSS ) , CSS , , , , 1024px, .

JQuery, .

0

All Articles