Reputation: 105
Is it possible to get event on starting page loading, when DOM structure isnt complete?
For example:
<?php
for ($i =0 ; $i<10000; $i++)
{
for($e=0;$e<1000;$e++) {
$f = 5 * 4 & 9;
}
}
echo "done";
?>
I have this php code, loading page in this case takes ~5 sec, and i want to event on start page loading and on the end of loading.
Event when site is ready i can get with
$( document ).ready(function() {
});
but on starting loading? Can someone help with it?
Upvotes: 0
Views: 51
Reputation: 425
Just write inline javascript at the start of your page, and before these PHP codes. The browser will execute inline JS as it reads it.
edited to add:
However, that won't work in your example, because in your example, it's not the page load that takes the time, it's the server-side page generation.
You'd have to use php's flush() to flush the output buffer and push the javascript to the browser before actually doing the work.
Upvotes: 1