Skip to content

Instantly share code, notes, and snippets.

@nternetinspired
Created July 16, 2012 08:34
Show Gist options
  • Select an option

  • Save nternetinspired/3121556 to your computer and use it in GitHub Desktop.

Select an option

Save nternetinspired/3121556 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