I just had a situation where I need to put ad in different location for mobile view. The placement is hard to solve via CSS appproach.
So I had to do some width detection inside Google Publisher Tag (GPT) slot definition, which is executed early and async.
For some reason $(document).width() is not always evaluated.
It appears that jQuery approach is best used after document ready event, which is not suitable for my purpose.
Fortunately Modernizr's media query function works in my case
... var isDesktopView = Modernizr.mq("screen and (min-width:970px)"); ....