My webpage performs a simple check to verify if Javascript and cookies are enabled on the client's browser. If they are enabled, the script displays the content inside div id="conteudo" and hides the warning message inside div id="aviso". If not, the script keeps the warning visible and hides the content.
Everything works perfectly on my offline project, but on the server, the page seems to load a bit slow. When certain conditions of the script occur (such as Javascript or cookies being disabled), I can see the warning message inside div id="aviso" for a fraction of a second before it disappears. This is not the experience I had planned. Does anyone know how I can fix this issue in my code? Thank you.
var JS_Enabled = false;
var C_Enabled = false;
$(document).ready(function()
{
//Test for JavaScript (if entered here, it's enabled).
JS_Enabled = true;
//Test for cookies.
var TEST_COOKIE = 'test_cookie';
$.cookie(TEST_COOKIE, true);
if ($.cookie(TEST_COOKIE))
{
$.cookie(TEST_COOKIE, null); //delete the cookie.
C_Enabled = true;
}
//Final evaluation.
if (JS_Enabled && C_Enabled)
{
$("#aviso").hide();
$("#conteudo").show();
}
else
{
$("#aviso").show();
$("#conteudo").hide();
}
});