jQuery UI .buttonset() is too slow
jQuery UI .buttonset() is too slow
我在HTML页面上有几千个按钮。在文档就绪上运行$(".buttonset").buttonset();
需要 10 秒以上。有没有更快的方法来做到这一点,或者我唯一的解决方案是以某种方式限制按钮的数量?
在
首次显示buttonset
之前按需创建它们。
我刚刚测试了分为 2400 个部分的 12 个盒子。它在我的i7上使用Chrome 23,Firefox 17,IE9,Opera 12运行流畅。
这可能会在您第一次打开复选框组时增加拆分加载时刻,但它确实会节省一些 RAM,因为它不会创建未使用的样式按钮,直到它们才被允许。
小提琴
对于buttonset()
设置数千个按钮所需的速度,您无能为力,但是如果您的 10 秒问题是浏览器消息,指出页面已无响应,您可以使用 setTimeout 调用将操作分解为异步操作。
$(".buttonset").buttonset();
会变成:
$(".buttonset").each(function(index, button) {
setTimeout(function() {
$(button).buttonset();
}, 0);
});
我已经成功地将此模式用于数千个jQuery UI对象,虽然它不会加快操作速度,但它将防止页面锁定,从而使其看起来工作得更快。
相关文章:
- Is onfling available for html, html5
- jQuery is not loaded
- reactRedux is not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Jquery - table.row(tr) is undefined
- contentWindow.document.body is null
- Tomcat websocket is not working
- noty.js is returning undefined
- $routeParams is undefined
- NodeJS Multer is not working
- React, Webpack: bundle.js is not generated
- jQuery is not defined - WordPress footer.php
- 谷歌地图API v3:Initial View is Fine,but Gray Box with No Map if
- imageArray[i] = imageItem is incompatible
- GAPI Is Not Defined
- Angular2 rc1, where is shims_for_IE
- Is (!~index) faster than (index === -1)?
- jQuery UI .buttonset() is too slow
- React/Redux bundle.js is too big
- Emscripten Uncaught RangeError: Source is too large, multipl