jqueryjQuery is just javascriptJavascript, Soso the question is really "Is it possible to run JavaScript before the DOM is ready" and with that I'm guessing you mean the document and not DOM.
If we can agree that the question is "Is it possible to run JavaScript before the document is ready". Then the answer is yes. The JavaScript will be executed when encountered.
That's waywhy you almost always see either $(function(){...})``or $(document).ready(function(){...})`or $(document).ready(function(){...}) because most jQuery code requires the document to be ready but the code attaching the event handler is certainly executed before the document is ready (otherwise it wouldn't be able to handle the document ready event).
usuallyUsually you shouldshould place your javascriptJavascript includes at the buttombottom of your htmlHTML but if you want it executed earlier you can simply place it earlier in the document e.g. in the header.
<html>
<head>
...
<script>
//place your code to be executed early here
</script>
</head>
...
</html>
jquery is just javascript, So the question is really "Is it possible to run JavaScript before the DOM is ready" and with that I'm guessing you mean the document and not DOM.
If we can agree that the question is "Is it possible to run JavaScript before the document is ready". Then the answer is yes. The JavaScript will be executed when encountered.
That's way you almost always see either $(function(){...})``or $(document).ready(function(){...})` because most jQuery code requires the document to be ready but the code attaching the event handler is certainly executed before the document is ready (otherwise it wouldn't be able to handle the document ready event)
usually you should place your javascript includes at the buttom of your html but if you want it executed earlier you can simply place it earlier in the document e.g. in the header
<html>
<head>
...
<script>
//place your code to be executed early here
</script>
</head>
...
</html>
jQuery is just Javascript, so the question is really "Is it possible to run JavaScript before the DOM is ready" and with that I'm guessing you mean the document and not DOM.
If we can agree that the question is "Is it possible to run JavaScript before the document is ready". Then the answer is yes. The JavaScript will be executed when encountered.
That's why you almost always see either $(function(){...})or $(document).ready(function(){...}) because most jQuery code requires the document to be ready but the code attaching the event handler is certainly executed before the document is ready (otherwise it wouldn't be able to handle the document ready event).
Usually you should place your Javascript includes at the bottom of your HTML but if you want it executed earlier you can simply place it earlier in the document e.g. in the header.
<html>
<head>
...
<script>
//place your code to be executed early here
</script>
</head>
...
</html>
jquery is just javascript, So the question is really "Is it possible to run JavaScript before the DOM is ready" and with that I'm guessing you mean the document and not DOM.
If we can agree that the question is "Is it possible to run JavaScript before the document is ready". Then the answer is yes. The JavaScript will be executed when encountered.
That's way you almost always see either $(function(){...})``or $(document).ready(function(){...})` because most jQuery code requires the document to be ready but the code attaching the event handler is certainly executed before the document is ready (otherwise it wouldn't be able to handle the document ready event)
usually you should place your javascript includes at the buttom of your html but if you want it executed earlier you can simply place it earlier in the document e.g. in the header
<html>
<head>
...
<script>
//place your code to be executed early here
</script>
</head>
...
</html>