Prevent Flickering In Web Page

Sometimes we add too much code in a web page and this causes the page to flicker. What it means is that imagine we have created a webpage that needs to show/hide some div part on a user clicking a dropdown.

Once we submit the data to our server (say SQl) the page gets reposted and all elements of default page becomes visible including some content of the page that should not be visible becomes  visible for a few seconds.

In order to prevent flickering we can add the below code under tag:

<script type=”text/javascript”> 

  1. document.write('<style type="text/css">body{display:none}</style>');  
  2.     jQuery(function ($) {  
  3.     $('body').css('display''block');  
  4.  }); 

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now