Use a call-back function to get the last modified date and time of the file you want to watch. The JS would execute an HTTP call to the PHP page which would read the last modified date and output it. JS would then compare the previous one it got. If they're differnet, refresh the image, if not, sleep until it's time to check again.