Thanks for quick reply.
for example i want to hide a button from unregistered users, but it shows up fro 4-5 seconds and then hides.
i am using
document.getElementById('btn').style.visibility = 'none';
on body load
Right, exactly, you are waiting until the page fully loads until you hide the button with your page load event. You should use
<input id="btn" type="button" style="display:none" />
Then your javascript onload event will check if the user is authenticated and display the button with:
document.getElementById('btn').style.display = 'block';
or
document.getElementById('btn').style.display = 'inline';