I have an HTML file with JavaScript that will be stored directly on my iPhone. What is the simplest way to open and run it there? I mainly want an offline calculator, so I'd prefer not to rely on a server unless that's necessary.
5 Answers
If you only have the iPhone, an online coding and hosting service can upload the HTML file and provide a URL. For a page you use regularly, turning it into a progressive web app and adding it to the home screen can also let Safari cache it for offline use and pick up updates later.
If the goal is eventually to make a real iPhone app rather than just run a webpage, look at a wrapper such as Capacitor or a native approach like Swift. That’s more work than hosting a webpage, but it avoids many of iOS’s restrictions on local files.
The most dependable option is to host the page somewhere and open its URL in Safari. You could publish it with GitHub Pages, use a simple hosting service, or run a development server on another computer and access it from the iPhone over your local Wi-Fi using the computer’s IP address and port.
You can try locating the file in the Files app and opening it with Safari. However, iOS may restrict or disable JavaScript for local files, so this approach isn’t reliable for an interactive page.
For a small loan-payment calculator, hosting the page as a simple static site is probably the easiest solution. Once it has a URL, Safari can run the JavaScript normally, and you can save the site to the home screen for quick access.

That was my experience too: the local page opened, but its JavaScript didn’t run.