Classic Solitaire in the Browser

Classic Solitaire has been a mobile game since 2012. As of this year it is also a web page: open it, click the stock, play. Nothing to install, no account, and no ads between hands.

Classic Solitaire running in a browser

The fashionable way to do this in 2025 would be to rewrite the game in JavaScript, or to push the C# through one of the WebAssembly toolchains and ship a few megabytes of runtime in order to draw fifty-two cards. I did neither, because the game did not need it. The core has been portable from the start: it began as Java, went through Sharpen into C#, and that C# has been feeding the iOS, Android and Windows builds ever since. It only wanted one more compiler at the end of the chain.

Script#

Script# turns C# into JavaScript, and it produces readable JavaScript rather than a runtime with C# hidden inside it, which is why I picked it. The header on the output says:

 * Copyright (c) 2012, Nikhil Kothari, and the Script# Project.
 * More information at http://scriptsharp.com

Because it is the same code, it is the same game. Same shuffle, same scoring, same rules about what may sit on what. I did not write a web version of Klondike. I compiled the one that already existed.

Some features did not make the trip. Nothing that changes how a hand plays, but the browser build is deliberately the plain one, and anybody who knows the mobile version well will find the gaps.

The half I had to write anyway

The rendering was never portable, on any platform. Every front end has always been its own code, going back to the Windows 8 port, where the hardest part turned out to be the cards jumping around at the end of a winning game.

So the browser got a canvas renderer written from scratch, sharing nothing with the mobile or desktop versions, and a modal dialog implementation to go with it, because the deck picker and the options screen had to live somewhere and I was not going to drag in a UI framework to draw a grey box with an OK button in it.

None of it is clever, and it is not meant to be. Draw the felt, draw the piles, draw the card under the cursor last. Keep the dialogs square. The whole point of this game is that it looks like the one that came with Windows, so the best thing the presentation layer can do is stay out of the way.

The site around it

The Classic Solitaire website

The game got a small site rather than a single page, because there was more to put around it: a leaderboard, the rules, and links to every other version. There are more of those than people expect. Links to the games, Klondike, FreeCell, Spider, Pyramid and TriPeaks, in free and paid editions, across the App Store, Google Play and the Microsoft Store.

And a blog about cards

There is also a blog, which is the part I did not plan and now like best. It’s not a changelog, but a set of articles about the games and the people behind them: where Klondike came from before Windows 3.0 got hold of it, what Draw One actually does to your odds against Draw Three, how FreeCell shipped on more desktops than almost anything and then got quietly retired, and the shuffling and solvability questions sitting underneath all of it.

And about Susan Kare, who drew the Windows deck. She had already done the original Macintosh icons, the Chicago typeface and the Command symbol; the cards are a footnote in that career and probably the most-looked-at thing she ever drew. The game itself was written by Wes Cherry as an intern, and he has said more than once that he was never paid for it. My deck is not hers, it never has been, it is a GPL deck recoloured to match. But the design everyone pictures when they hear the word solitaire is Susan Kare’s.

Comments and likes happen on the blog’s Facebook page, which is less work than moderating my own.

Two addresses

The site is at cardsolitaire.win, and mirrored at runserver.net/solitaire.

A thirteen-year-old codebase, run through a compiler last updated in 2012, drawing a deck that imitates one from 1990 onto a canvas element. It works. On the first run it even showed the right picture for a moment and then crashed the browser. 🙂