如何使用 ajax 加载你的融合页面,这样慢速宏不会减慢页面加载速度

发布于 2024-08-22 08:13:45 字数 99 浏览 2 评论 0原文

一些使用宏的页面,例如:

topusers 或popularlabels,

加载速度确实很慢。有没有办法通过ajax异步加载,而不是阻止初始页面加载?

some pages that use macros like:

topusers or popularlabels

are really slow to load. Is there any way to have this load asynchronously through ajax instead of having this block the initial page load ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

在梵高的星空下 2024-08-29 08:13:45

Future 宏绝对是 100% 最好的方法。

我们在 Confluence 2.10.3 实例上大量使用它来加速一切,但我还没有使用更新的版本对其进行测试。

https://labs.atlassian.com/wiki/display/FUTURE/Home

我制作了一个小视频来展示它的工作原理 - 访问 SharePoint 服务器来呈现文档列表。这不是一个完美的演示,但可以让您了解它的作用。

我也制作了一个视频,但还没有 StackOverFlow 代表将其发布到这里,所以这里是 URL 的一部分
screencast.com/t/tz8xdSCQYxp

布伦丹

The Future macro is absolutely 100% the best way to do this.

We use it massively on a Confluence 2.10.3 instance to speed up everything, but I haven't tested it with more recent versions.

https://labs.atlassian.com/wiki/display/FUTURE/Home

I made a little video showing it working - reaching out to a SharePoint server to render a document list. This is not a perfect demo but gives you an idea of what it does.

I made a video of this too, but don't have the StackOverFlow rep to post it here yet so here is part of the URL
screencast.com/t/tz8xdSCQYxp

Brendan

如果您考虑使用 jQuery 库,它内置了对异步 ajax 请求的支持。

If you consider using jQuery library, it has build-in support for asynchronous ajax requests.

那片花海 2024-08-29 08:13:45

也许谷歌分析方法会对你有所帮助。

(function() {
    var delayed = document.createElement('script');
        delayed.type = 'text/javascript';
        delayed.async = true;
      delayed.src = 'URL_AD_SERVER';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(delayed);
})();

但是,我不知道依赖项如何工作:)

Maybe google analytics approach will help you.

(function() {
    var delayed = document.createElement('script');
        delayed.type = 'text/javascript';
        delayed.async = true;
      delayed.src = 'URL_AD_SERVER';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(delayed);
})();

However, I don't know how will work for dependencies :)

月光色 2024-08-29 08:13:45

实际上,您所需要做的就是推迟加载,直到页面加载完成。为此,您可以创建一个 javascript 函数来设置您正在加载的内容的脚本标记,然后当正文加载完成时,调用此函数。您可以通过以下方式做到这一点:

function loadConfluence() {
 var ads = document.createElement('script');
 ads.async = true;
 ads.src = 'your_ad_url';
 return document.getElementsByTagName('body')[0].appendChild(ads);
};
window.onload = loadConfluence();

This code will wait until the page is fully loaded and then call the function to load your ads.

Really all you need to do is postpone the loading until after the page has loaded. To do that, you can make a javascript function that sets the script tags of what you are loading and then when the body is done loading, call this function. You can do that by:

function loadConfluence() {
 var ads = document.createElement('script');
 ads.async = true;
 ads.src = 'your_ad_url';
 return document.getElementsByTagName('body')[0].appendChild(ads);
};
window.onload = loadConfluence();


This code will wait until the page is fully loaded and then call the function to load your ads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文