当我克隆图像时,浏览器是否会重新下载该图像? Chrome 控制台显示从缓存中加载,但是
当我在移动浏览器 (ios) 上查看时,是否有相当大的延迟?
$('#a').on('click', function() {
$(this).clone().appendTo('body');
})
#a {
width: 200px;
height: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img id="a" src="https://www.pcspecialist.co.uk/images/misc/right-pc.png" alt="">
最佳答案
我遇到了这个问题,我通过对图像进行 base64 编码并使用 data URI 解决了这个问题将其嵌入到 html 中。随着它的嵌入,它被克隆而无需额外的请求。但是,请注意,如以下问题中所讨论的,数据 URI 存在折衷:How much faster is it to use inline/base64 images for a web site than just linking to the hard file?
关于无需重新加载的 Jquery 克隆图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47895483/