Performance issue with zClip and multiple buttons

330 Views Asked by At

I added the zClip on my page which works pretty fine. My page currently has 100 buttons that put text on the clipboard (requirement).

Unfortunately this causes a performance issue when the page loads. At the moment i use a code like the one below.

$('.myClass').each(function(){
    $(this).zclip({
        path :  '/script/ZeroClipboard.swf',
        copy : function(text){
                return "Some Text";
            }
    });
});

With Zeroclipboard i had not performance issues with the exact same implementation. Is there any workaround or something that could fix this issue ?

2

There are 2 best solutions below

1
On
$(".myClass").click(function(){
    $(this).zclip({ 
        path: "/script/ZeroClipboard.swf",
        copy : function(text){
                return "Some Text";
        }
    });
});
0
On

Just had the same problem. Changed it to load zclip into the element on mouseover of the element. Should probably add checks/flags to element so it doesn't get loaded onto the element multiple times.

$('.myClass').on("mouseover", function(){
    $(this).zclip({
        path :  '/script/ZeroClipboard.swf',
        copy : function(text){
                return "Some Text";
            }
    });
});