understanding jQuery $.getScript()

后端 未结 5 1562
情歌与酒
情歌与酒 2020-12-28 09:39

I use getScript to load dynamically my plugin:

$.getScript(\'js/code.photoswipe.jquery-3.0.4.min.js\', function () {
   //do magic
});
5条回答
  •  温柔的废话
    2020-12-28 10:36

    1 . jQuery 1.12.0 and later supports the options object signature:

    $.getScript({
        url: "foo.js",
        cache: true
    })
    

    2 . Assuming you set cache:true the file will be loaded from the browser cache (unless browser cache is disabled or expired, for example when devtools is open)

提交回复
热议问题