提问人:Praveena Dewars 提问时间:3/1/2022 更新时间:3/1/2022 访问量:31
如何使网站投资组合部分中的项目下拉列表加载速度更快?
How can I make the project dropdowns in the portfolio section of my website load faster?
问:
我的网站加载得很好,但是当我尝试打开我的作品集部分中的任何项目时,加载时间可能太长了 - 桌面和移动。
这是我认为可能导致这种情况的代码片段 - 我不确定要进行哪些更改来修复它,请帮忙。
谢谢
`jQuery('.portfolio-item a').on("click", function(e) {
e.preventDefault();
var $that = jQuery(this);
var $item = $that.closest(".portfolio-item");
if ($item.find('.loading').length===0) {
jQuery('<div />').addClass('loading').appendTo($item);
$that.parent().addClass('active');
var $loading = $item.find('.loading'),
$container = jQuery('#portfolio-details'),
timer = 1;
if ($container.is(':visible')) {
closeProject();
timer = 800;
$loading.animate({width:'70%'}, {duration:2000, queue:false});
}
setTimeout(function() {
$loading.stop(true, false).animate({width:'70%'},
{duration:5000, queue:false});
//Add AJAX query to the url
var url = $that.attr("href")+"?ajax=1";
jQuery.get(url).done(function(response) {
$container.html(response);
$container.waitForImages(function() {
$loading.stop(true, false).animate({width:'100%'},
{duration:500, queue:true});
$loading.animate({opacity:0}, {duration:100,
queue:true, complete:function() {
$that.parent().removeClass('active');
jQuery(this).remove();
$container.show().css({opacity:0});
that.imageSlider($container, function() {
jQuery(document).scrollTo($container, 600,
{offset:{top:-parseInt(jQuery(".navbar").height(), 10), left:0}});
$container.animate({opacity:1}, {duration:600,
queue:false});
$container.attr('data-current',
$that.data("rel"));
});
}});
});`
答: 暂无答案
评论