-2

I am trying write a code to load different scripts for different resolution eg. for desktop it should be different scripts and also for mobile iPad etc different scripts

I am trying with this code but don't know where to start exactly

if ( $(window).width() > 800) { 
    <script type="text/javascript" src="js/jquery.slimscroll.min.js"></script>
    <script type="text/javascript" src="js/jquery.fullPage.js"></script>
    <script type="text/javascript" src="js/examples.js"></script>

    $('#fullpage').fullpage({
        anchors: ['firstPage', 'secondPage', '3rdPage'],
        sectionsColor: ['#C63D0F', '#1BBC9B', '#7E8F7C'],
        css3: true
    });
}
else {
    // do Something ...
}
Adeel
  • 2,901
  • 7
  • 24
  • 34
Divya Sharma
  • 237
  • 1
  • 6
  • 17

1 Answers1

0

You should be able to do it like this:

if(...){
  document.write('<script  type="text/javascript" src="..."><\/script>');
}
else{
  document.write('<script type="text/javascript" src="..."><\/script>');
}

See Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail

Community
  • 1
  • 1
David Sulc
  • 25,946
  • 3
  • 52
  • 54