You can use various methods for this.
The easiest and easiest way is to simply add a script tag to the end of the body tag:
<html> <head> <title> Example </title> </head> <body> <div> <p>Hello</p> </div> <script type="text/javascript"> </script> </body> </html>
The jQuery method does something similar to:
window.onload = function() {
Usually I just do it the second way, just in case.
To ensure compatibility with multiple browsers, go through the jQuery source and find what they use.
source share