I want to call function before document get ready, so is there any method in Jquery to do this?
Asked
Active
Viewed 9.3k times
35
-
AFAIK no, but there may be ways to simulate it by placing the script at the right location. What are you trying to do, what is your end goal? – Pekka Aug 25 '11 at 08:03
-
1Call the function outside of document ready! – Shef Aug 25 '11 at 08:03
-
possible duplicate of [Running a function just before $(document).ready() triggers](http://stackoverflow.com/questions/4098504/running-a-function-just-before-document-ready-triggers) – Haim Evgi Aug 25 '11 at 08:03
-
1Call ur function anywhere in dom, it will be called before dom is created. – hungryMind Aug 25 '11 at 08:04
3 Answers
27
Just call your function before the document ready statement.
<script>
thisWillFireImmediately();
$(function() {
thisWillFireOnDocumentReady();
});
</script>

Scott
- 2,753
- 1
- 24
- 31
-7
If you are using .hide() or display: none; - the hiding of the divs will be displayed.
try:
visibility: hidden;
it worked for me after trying many other ways.

leenbean16
- 134
- 12