如果带有<超过600px

Load jquery conditionally with pure JavaScript if windows with < than 600px

本文关键字:超过 600px lt 如果      更新时间:2023-09-26

如果windows带有<超过600px,并放置一个以异步方式加载jquery的"else"?

类似的东西?

var sync;
if (window.outerWidth < 600) {
  sync = false;
} else {
  sync = true;
}
function loadScript(sync) {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.async = sync;
  script.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.js";
  document.getElementsByTagName("head")[0].appendChild(script);
};
loadScript(sync);