Reputation: 1565
Basically I want to load a particular jquery plugin on smaller viewports, and then on larger ones deinitialize it and initialize a different one?
Upvotes: 1
Views: 484
Reputation: 4771
This does not account for window resizing, but perhaps it will set you in the right direction.
$(document).ready(function() {
var viewportWidth = $(window).width();
var viewportHeight = $(window).height();
var widthThreshold = 1000;
var heightThreshold = 800;
var scriptUrl;
if (viewportWidth > widthThreshold &&
viewportHeight > heightThreshold){
scriptUrl = "plugin1.js";
}
else {
scriptUrl = "plugin2.js";
}
$.getScript(scriptUrl);
};
Upvotes: 2