Modernizr .load() for jquerymobile lag issue
-
09-01-2021 - |
题
I am attempting to use modernizr.js to use a media query "mq()" and load ".load()" to have a jquerymobile version of a website fire on load based on the media query result, i am having issue with the .load() function
testing in safari, something is causing a large lag, having the resources load after all the content after pointing to the modernizr.js, i have tried
<script type="text/javascript" >
Modernizr.load('js/jqm-b2.js');
</script>
and have tried this
Modernizr.load([
{
test : Modernizr.mq('only screen and (min-device-width: 768px) and (max-device-width: 1024px)'),
yep : ['js/jqm-b2.js'],
nope : ''
}
}
]);
both give the same result, page displays content then loads the scripts after the fact, so that the page jumps from html to suddenly jquerymobile enhanced
I used the production modernizr download, and selected media queries and load.
Any help is greatly appreciated
解决方案
ended up solving like this, made sure it loaded either/or rather than just or
Modernizr.load([
{
test : Modernizr.mq('only screen and (min-device-width: 320px) and (max-device-width: 768px)'),
yep : ['js/jqm-b2.js'],
nope : ['js/desktop.js'],
...
不隶属于 StackOverflow