I have a common question, I have a webpage done with HTML,CSS and JQuery. When the page starts loading, It first loads the html and displays divs for a second which are supposed to be hidden by css and jquery. But after a second, it looks perfect. But that first second looks terrible. How can I avoid that?
I've not had such an experience but I think the loading procedure for your scripts should help here. Depending on what the page is meant to do (unknown to me), I prefer you try loading this way.
Display the div using CSS
<div style="display: none;">Hidden by default</div>
Load your JQuery files before the closing of your body tag.
When page is fully loaded it can then function well.
$(this).hide();
or $(this).addClass('.hidden');
is always slower than .class { display:none; }
jQuery has to wait for the DOM to load. CSS doesn't. Set your CSS to hide the elements you need to hide on load, then use jQuery to show those element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With