How to Run the Khan Academy Off‑Line

With a basic knowledge of HTML, you can tailor this complex app to your needs

4 min read
Illustration: Jesse Lefkowitz
Illustration: Jesse Lefkowitz

When a friend recently asked for volunteers to help tutor inmates at a local prison, I asked, “Why not use the Khan Academy?”

This website contains a wealth of video tutorials that span a wide range of topics and complexity, ideal for inmates seeking high school equivalency diplomas. The math offerings are probably the most complete—ranging in difficulty from basic addition to linear algebra and calculus—but the site has lessons in astronomy, art history, economics, chemistry, biology, physics, and more.

The academy has received considerable media coverage. So it’s easy to find out lots about it—how it began with a few simple videos Salman Khan made to help tutor a cousin in math, how his lessons unexpectedly went viral on YouTube, how Bill Gates took an interest and funded the expansion of his work, and how the academy has become a pillar in some technologically progressive schools. Khan and a small team of programmers are now on a mission to provide “a free world-class education to anyone anywhere.” And they seem well on their way.

What’s harder to discover is how the Khan Academy works under the hood. In particular, the website includes not just videos but exercises generated on the fly to test whether you’ve understood a lesson. It also provides sophisticated tools for teachers, allowing these “coaches,” as Khan labels them, to monitor how students are doing with their self-paced learning. So it’s a rather complex Web application. And that made for a problem: Prisoners are not allowed Internet access.

Fortunately, the open-source Khan Academy provides an off-line-capable version of its site. Go to https://khanacademy.org and scroll to the bottom of the home page. Clicking on Downloads takes you to a short description of the academy’s off-line server and a link to the download page, where you’ll find three off-line-capable packages—for Windows, Linux, and Mac OS. Apart from some difficulties I had getting this to run on my 64-bit Windows 7 machine, there’s a fundamental problem with the version offered there (revision 8051): When you attempt the exercises off-line, an error message reports that access to Google.com is needed.

While the ability to watch Khan’s videos off-line would be a valuable thing in itself, it seemed a shame to miss out on Khan’s computer-generated exercises. Happily, with a little digging I discovered that earlier versions of the Khan Academy Web application will run the exercises off-line. Return to the downloads page and search “All downloads” (leave the search box blank). You’ll then see links to several previous versions.

I grabbed the file KhanAcademy-1482.zip, unzipped it, and soon had a version running that could serve exercises and coaching tools off-line. To get the videos, you’ll need to follow the instructions in the Read.me file. This automates the download of some 2100 videos—fewer than the current crop (around 3200) but still an ample supply. It took me more than a day to download the 23.5-gigabyte collection.

khan academy screenshot view

Images: David Schneider
Act Locally: A little hacking makes the Khan Academy home page [top left] look presentable when hosted on your local machine, and a simple fix allows the site’s helpful knowledge map to appear [top right]. Students can use the off-line version to watch Khan’s educational videos and to do practice exercises [bottom left], and teachers can access the various monitoring tools [bottom right]. Click on the image to enlarge.

So how does the off-line version work? The Khan Academy uses Google App Engine, a cloud service, to host its website. That is, Google serves the Khan Academy website, created dynamically by the Khan Academy’s software running on Google’s machines. But Google also provides a version of its app engine that can run locally—used normally for development purposes to test Web-application code before deploying it on Google’s infrastructure. The off-line version of the Khan Academy runs just on this local development app server. Once everything is installed, you view it by pointing your browser to https://localhost:8080.

There are some complications. For one, the Web app sometimes tries to fetch things from the Internet. In particular, the home page contains an embedded YouTube video player to show media coverage of the Khan Academy. Without an Internet connection, there’s just a big blank space on the home page instead.

That looks bad. So I replaced the HTML for that YouTube video player with a couple of lines that link to an image from a “PBS NewsHour” story on the Khan Academy. The image I used is a screen shot from the opening moments of that news story. Now you see newscaster Judy Woodruff, rather than a bunch of white space, on the home page. And because not all of the news-report videos advertised on the home page come in that 23.5-GB download, I added a disclaimer line to the home page noting that only some of the media coverage can be viewed off‑line. Another infelicity was a set of links to YouTube, Twitter, and Facebook at the top of the pages. As these social networking sites aren’t available, I removed them from the relevant HTML template.

My biggest disappoint­ment with the off-line version was that the exercise dashboard didn’t show Khan’s lovely “knowledge map,” a graphical representation of how his math lessons are conceptually organized, which helps you keep track of what you’ve mastered and what you have next to tackle. The dashboard even indicated that the knowledge map was unavailable in off‑line mode. But I found that if I navigated away from the exercise dashboard and then clicked the back button on my browser, the knowledge map would mysteriously materialize.

I don’t understand the mechanism behind this odd behavior, but I figured I could nevertheless take advantage of it. In place of the notification that the knowledge map isn’t available off-line, I put a link to show the knowledge map. That link sends you to a dummy page I created, which includes nothing but a bit of JavaScript that simulates hitting the back button. Users still don’t see the knowledge map when they first load the exercise dashboard, but when they click on the new show-the-knowledge-map link, the map appears.

These modifications really weren’t necessary, but they make the off-line version look a bit sharper. And they demonstrate the power of having access to the source code. You don’t need to understand how everything works—I certainly don’t—to be able to customize even a complex Web application to meet your needs.

I was trying to come up with an educational resource for inmates, but others are using the Khan Academy off-line in very different settings, such as for teaching children in remote African villages that don’t have Internet access. It’s easy to imagine more prosaic uses, too—you might just want to use it as a backseat “game” during family car trips. Whatever your purpose, an off-line Khan server is easy to set up, and with a little hacking you can tailor it to your liking.

This article originally appeared in print as “Khan Academy Unplugged.”

This article is for IEEE members only. Join IEEE to access our full archive.

Join the world’s largest professional organization devoted to engineering and applied sciences and get access to all of Spectrum’s articles, podcasts, and special reports. Learn more →

If you're already an IEEE member, please sign in to continue reading.

Membership includes:

  • Get unlimited access to IEEE Spectrum content
  • Follow your favorite topics to create a personalized feed of IEEE Spectrum content
  • Save Spectrum articles to read later
  • Network with other technology professionals
  • Establish a professional profile
  • Create a group to share and collaborate on projects
  • Discover IEEE events and activities
  • Join and participate in discussions