Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cmarkle27/4087028 to your computer and use it in GitHub Desktop.
Save cmarkle27/4087028 to your computer and use it in GitHub Desktop.
Conditional resource loading, using Modernizr's yepnope tests, based on viewport size. Placed immediately before the closing head tag in index.php this can be used to load specific resources against reported viewport sizes
<!-- Something like this -->
<script>
Modernizr.load({
test: Modernizr.mq('(min-width:400px)'),
yep: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/not-small-screen-stuff.js">',
});
</script>
<!-- Or -->
<script>
Modernizr.load({
test: Modernizr.mq('(min-width:1024px)'),
yep: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/big-screen.css">',
nope: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/small-screen.css">',
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment