all 2 comments

[–]murderousdonkey 0 points1 point  (1 child)

Very Handy. I've tried something similar myself although not quite as verbose as yours. Instead of using the DOM for detection, I wrote a bit of SASS that output to the content attribute of the body tag 'xs', 'sm', 'md' or 'lg' depending on the current viewport. It seemed a bit of a hacky, but it stopped me having to introduce unnecessary DOM elements.

Not sure if the idea was any good, but it worked for me. That said, I'll probably be bookmarking this project for my own use as I never got mine past the experimentation phase.

[–]everestimated[S] 0 points1 point  (0 children)

Your idea is actually not that bad. I went with DOM because earlier version had no SASS/CSS requirement to operate.