Menu icon Foundation
Javascript media queries without onready

Hello!

I use https://github.com/js-cookie/js-cookie (not require Jquery) to set the current breakpoint, like this


$(function () {

  $(document).foundation();

  var query = Foundation.MediaQuery.current;
  Cookies.set('mediaquery', query, { expires: 7 });

});

This gives me the opportunity to get the value in php (if $_COOKIE["mediaquery"] == 'small') ..etc) and display a variety of information (different banners for example on different screen) to the user. The problem is that function "Foundation.MediaQuery.current" only works onready, depends on jquery, so cookies can not be placed immediately, wait for the DOM ready.

Is there any solution to get foundation current media queries without jquery? 

 

 

jquerymedia queries

Hello!

I use https://github.com/js-cookie/js-cookie (not require Jquery) to set the current breakpoint, like this


$(function () {

  $(document).foundation();

  var query = Foundation.MediaQuery.current;
  Cookies.set('mediaquery', query, { expires: 7 });

});

This gives me the opportunity to get the value in php (if $_COOKIE["mediaquery"] == 'small') ..etc) and display a variety of information (different banners for example on different screen) to the user. The problem is that function "Foundation.MediaQuery.current" only works onready, depends on jquery, so cookies can not be placed immediately, wait for the DOM ready.

Is there any solution to get foundation current media queries without jquery?