Small web browser

Since we are in the subject of small programs, is there are any small GUI web browser? Less than 50K, perhaps? I must be joking, right?

Well, you _could_ make a small web browser like that. Just make GUI shell that links in libwebkit.so. Yeah. That would work. May as well create a shell script that launches firefox. Hey, small browser in 512 bytes!

Seriously, can we have a small browser, without external dependency, that weight less than 500K (excluding the weight of the GUI toolkits)?

The answer is you can; and the key to that is libgtkhtml2. This is a HTML 4.0, CSS2 compatible rendering engine that weighs less than 500K. Since it is small it makes sense to have this as part of the system library (it is used by the likes of Osmo, Claws mail, etc for example); and if you already have it as a system library then you can truly makes a browser with the size of less than 50K, linking in this library.

If you don't have it as system library, you can still link it statically and have final stripped executable that is less than 500K (the exact size depends on your compiler optimisation settings, etc).

I have made such a browser, and you can download the source here. In Fatdog64, that has libgtkhtml2 by default, the binary size is really 38K. Linked in statically, with -Os, the binary size is about 350K (on x86_64 build).

Note about libgtkhtml2 source: as you can probably see from the link given, libgtkhtml2 is a dead project. That gnome site listed version 2.11.1 as its final version, but there is (or was) a newer version from gnome-svn (which had also long been defunct) - which, fortunately, has been preserved by the Yocto project here. I took this version, applied as many forward patches I could find (mainly from the also defunct svn.o-hand.com - and also preserved by Yocto), and added my own stability patches. This final copy of libgtkhtml2 of mine is located here.

Final note: libgtkhtml2 is old. It *will* choke, hang or crash on newer CSS3 (and some CSS2.1) or HTML5 stuffs. It does not have Javascript. While its HTML parsing is not too bad (it uses libxml2's html parser - which *is* maintained), its CSS parsing is horrible - instead of a grammar-derived parsing, it uses ad-hoc string searches. I have fixed some of the low-hanging bugs but a lot more still lurks in it. So I strongly advise you against using it for general purpose web browsing - for that you can have netsurf, links2, or other excellent projects - and while they aren't as small as libgtkhtml2, they do work for modern Internet.

The only reason why I tried to resurrect this, is to use it as a small (local) help viewer for HTML contents - just like mdview, in my previous post. After all, you don't want a help viewer that links to multi-megabytes webkit libraries, do you?



Posted on 12 Jun 2015, 05:58 - Categories: Linux General
Edit - Delete


No comments posted yet.

Add Comment

Title
Author
 
Content
Show Smilies
Security Code 2876641
Mascot of Fatdog64
Password (to protect your identity)