IPad and jQuery hide () on page load have a big delay

I wrote a little jQuery that hides a specific element when loading a page, which works fine on Mac browsers, but when I try to use it on an iPad, the page appears noticeably when the element appears and then disappears. This is the iPad that is causing the problem, in which case I may have to review the page loading process.

To hide the element I'm using:

$(document).ready(function() {
    $('#element').hide();
});

Another jQuery later shows the element when I click on things, so I could hide it with css, but this will not degrade the quality in the absence of js.

+3
source share
2 answers

html ( javascript) CSS ?

Javascript

<script type="text/javascript">
document.documentElement.className = 'js';
</script>

Css ( )

.js #element{display:none;}

<head> , .

: http://jsfiddle.net/C2jdX/

+4

, , script body, ready. :.

<!DOCTYPE html>
<html>
<head>
<!-- blah blah blah -->
<script src='path_to/jquery.js'></script>
</head>
<body>
<!-- blah blah blah -->
<div id='element'>...</div>
<!-- blah blah blah -->
<script>
    $('#element').hide();
</script>
</body>
</html>

script , .

, ( , - ).

:

+2

Source: https://habr.com/ru/post/1792817/


All Articles