开发者

When an iFrame imports a JS library, does the browser actually import the library a second time?

I've developed a Google-home like portal for my school, and these wid开发者_开发技巧gets all work as separate iFrames. In creating this, I noticed that you must re-import JS libraries in each iFrame.

My question is this: would it be terribly inefficient if multiple iFrames imported the same library? Would the client have to download the same library multiple times? If so, is there a way to use the same library you already imported in the parent?

Thanks!


It gets cached by the browser so the browser uses it from the cache itself.


No, once it's loaded, it's cached by the browser. This is why using JQuery from the Google CDN is beneficial because if anybody has visited any other website which has pulled JQuery from that same URL, it'll be pre-cached on their browser when they visit your site, and you get a bonus :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜