Tip: Improve resizing performance
September 24th, 2008 | Published in Google Desktop API
If your gadget has lots of visual elements, resizing might get very slow. This happens because
onsize
is triggered often when the user resizes your gadget. Use code like this to improve the performance of resizing:
var resizeTimeout = null;The
function view_onSize() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(resizeGadget, 10);
}
function resizeGadget() {
debug.info('Now I really resize everything');
... code to resize and relayout the gadget's contents ...
}
resizeGadget()
function is called only when the user is either finished with resizing or doesn't resize for a few milliseconds. The result is fewer redraws of your gadget and a smoother resizing experience for your user.Have a tip you'd like to share? Send it to gd-developer AT google DOT com. To see all tips, choose the Tips label.