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”>
- document.write('<style type="text/css">body{display:none}</style>');
- jQuery(function ($) {
- $('body').css('display', 'block');
- });