You can use the JavaScript version of Astronomy Engine to perform client-side astronomy calculations in a web browser. Calculations are offloaded to the visitor's computer.
Just grab a copy of
astronomy.browser.js
or the minimized astronomy.browser.min.js
and save it on your server. Inside your HTML code, pull in the script as usual:
<script src="astronomy.browser.js"></script>
There are no external dependencies! Astronomy Engine is completely self-contained, and it always will be.
(By the way, you can use the file astronomy.js
for
astronomy calculations in Node.js programs.)
All the functionality is wrapped inside an object called Astronomy
.
This is an example of a functioning page that uses Astronomy Engine to calculate some live information about the Moon.
Here are more example html files showing how to use Astronomy Engine in a web browser.
Determines the Moon's current phase and predicts when the next few quarter phases will occur.
Given a location of an observer on the Earth, calculates the amount of time it takes for a radar pulse to travel from that observer to the Moon and reflect back.
Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
The Node.js examples page has additional JavaScript examples that can be adapted to the browser environment, using the same Astronomy Engine source code.
Complete documentation for all the functions and types available in the JavaScript version of Astronomy Engine.