Skip to content

Instantly share code, notes, and snippets.

@jruck
Last active August 29, 2015 13:57
Show Gist options
  • Save jruck/9742401 to your computer and use it in GitHub Desktop.
Save jruck/9742401 to your computer and use it in GitHub Desktop.
conditionally loading content based on CSS breakpoints
/* CSS for setting variable within breakpoint */
@media all and (min-width: 45em) {
body:after {
content: 'widescreen';
display: none;
}
}
/* JS for fetching variable */
var size = window.getComputedStyle(document.body,':after').getPropertyValue('content');
/* JS for doing stuff if breakpoint reached */
if (size == 'widescreen') {
// Load some more content.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment