javascript - Modernizr.mq in vanilla JS -


i'm trying rid of modernizr in project can't seem understand or find replacement .mq function. can explain or provide bare solution problem?

according modernizr docs, mq checks whether page current matches media query pass it, e.g. if (modernizr.mq('(min-width: 900px)')) test if window @ least 900px wide.

on vaguely-modern browsers (ie10+, details here), can use window.matchmedia that. example page:

if (window.matchmedia("(min-width: 400px)").matches) {   /* viewport @ least 400 pixels wide */ } else {   /* viewport less 400 pixels wide */ } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

php - Cannot override Laravel Spark authentication with own implementation -

What is happening when Matlab is starting a "parallel pool"? -