我在div中有几个SoundCloud iframe。我期待只在看到div时加载它们。目前我正在通过我在网上找到的一种方法加载它们,这种方法逐个加载它们但仍然没有真正公正地对待我。
我要做的是在加载网站时降低网站的加载时间。由于SoundCloud减慢了网站速度,因此应该加快速度。
接近iframe的急切加载。
这是我到目前为止所做的:
HTML
<div class="gallery-cell">
<div class="div-img-content">
<div class="soundcloud-wrapper" id="236517781"></div>
</div>
<div class="div-icon-name">
<img src="<?php bloginfo('template_url')?>/assets/gallery_content/icon-music.png" alt="">
Terryl E
</div>
</div>
JS
function loadSoundcloud () {
$(".soundcloud-wrapper").each(function() {
var URL = $(this).attr('id');
var htm = '<iframe width="100%" height="200px" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' + URL +'&auto_play=false&hide_related=false&show_comments=false&show_user=false&show_reposts=false&visual=true" frameborder="0"></iframe>';
$(this).html(htm).fitVids().removeClass('.loading');
});
}
答案 0 :(得分:0)
在Melvita的鼓励下,我选择了https://softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect并将我的加载时间缩短了一半!它还将初始请求从400减少到48.
非常感谢。