smart rendering using jQuery
After using @Rino Raj's answer, I noticed that it needs to be improved.
In javascript, the load () or onload () event is in most cases much slower because it expects loading of all content and images before executing attached functions.
While the event attached to the jQuerys ready () event is executed as soon as the DOM is fully loaded, or all the markup, JavaScript and CSS content, but not the image.
Let me explain this based on code. When I used the @Rino Raj code with the load () event, it works, but the content appears on the second / called page before class = "hide fade" is added (which I don't want).
Then I reorganized the code using the ready () event, and yes, the content that I intended to hide / disappear does not appear at all. Follow the code below to understand the concept.
<script type="text/javascript"> $(document).ready(function() { sessionStorage.setItem('dontLoad', 'true'); }); </script> <script type="text/javascript"> $(document).ready(function() { if(sessionStorage.getItem('dontLoad') == null) { $("#more--content").removeClass("hide fade"); } else { $("#more--content").addClass("hide fade"); } }); </script>
Mwami tovi
source share