I have looked around and I\'ve seen one solution where in your html, you\'d have a tag dedicated to pass sass variables to javascript. I\'m talking about the second answer f
Not sure about "industry standard", but it's a very handy technique and not too difficult. The content of pseudo elements is not available via text() though, you have to use getComputedStyle.
Example using body:after:
Sass (using the compass breakpoint extension):
body:after {
display: none;
@include breakpoint($bp-wide) {
content: "wide";
}
@include breakpoint($bp-medium) {
content: "medium";
}
@include breakpoint($bp-small) {
content: "small";
}
}
JavaScript:
if (window.getComputedStyle) {
var mq = window.getComputedStyle(document.body,':after').getPropertyValue('content');
}
if (mq.indexOf('small') !== -1) {
// do something
}
Credit: I first saw this technique here: https://coderwall.com/p/_ldtkg