Skip to content

Commit a4f7cdc

Browse files
authored
Update jquery-before-ready.js
1 parent c808a8a commit a4f7cdc

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

jquery-before-ready.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1-
// Load this script immediatley after jQuery, or as as early as possible.
2-
// Then use .beforeReady instead of .ready(), e.g.
3-
//
4-
// $.beforeReady(function() {
5-
// alert("Ere I am JH")
6-
// });
7-
//
1+
/*
2+
Load this script immediatley after jQuery, or as as early as possible.
3+
Then use .beforeReady to execute code before any .ready() functions, e.g.
4+
5+
$.beforeReady(function() {
6+
alert("Ere I am JH")
7+
});
8+
9+
10+
Here is an example html file showing how the .beforeReady() function executes before the .ready() function.
11+
<html>
12+
<head>
13+
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
14+
<script src="jquery-before-ready.js"></script>
15+
</head>
16+
<body>
17+
<script>
18+
$(document).ready({
19+
alert("This function is declared first!")
20+
})
21+
</script>
22+
<script>
23+
$.beforeReady(function(){
24+
alert("This function is declared second but executes first!")
25+
})
26+
</script>
27+
</body>
28+
</html>
29+
*/
30+
31+
832

933
jQuery.beforeReadyPrivateArray = []
1034
jQuery.beforeReady = function (handler) {

0 commit comments

Comments
 (0)