I submitted the following patch upstream at webkit.  What this does is
adding a knob to disable DNS prefetching.  This makes web surfing
significantly snappier.  Pages like news.google.com load in < 1s instead
of 10s of seconds.  Same for other pages like slashdot, ars (you know
the ones with omgtracking and ad poop).

Sites like news.google.com (~350 DNS lookups for this particular one!)
prefetch all domain names over DNS while loading a page.  Since there
are limited slots for sockets it slows down the entire process of page
loading.  DNS prefetching is an artifact from modem times to speed up a
user click.  As the web has evolved people added more and more links to
pages and since throughput is faster with some DNS caching no one ever
went back and got rid of this bad bad bad idea.  They traded a perceived
performance issue by creating an actual one.

Don't even get me started on DNS tracking and other security
considerations.

I am posting this so that people can play along with this.

The xxxterm patch:
Index: xxxterm.c
===================================================================
RCS file: /cvs/xxxterm/xxxterm/xxxterm.c,v
retrieving revision 1.348
diff -u -p -u -p -r1.348 xxxterm.c
--- xxxterm.c   8 Mar 2011 23:19:36 -0000       1.348
+++ xxxterm.c   8 Mar 2011 23:19:50 -0000
@@ -6619,6 +6619,8 @@ void
 setup_webkit(struct tab *t)
 {
        g_object_set(G_OBJECT(t->settings),
+           "dns-prefetch", FALSE, (char *)NULL);
+       g_object_set(G_OBJECT(t->settings),
            "user-agent", t->user_agent, (char *)NULL);
        g_object_set(G_OBJECT(t->settings),
            "enable-scripts", enable_scripts, (char *)NULL);


The webkit patch is against the port NOT the direct tarball (for
convenience).

Index: Makefile
===================================================================
RCS file: /cvs/ports/www/webkit/Makefile,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 Makefile
--- Makefile    8 Mar 2011 18:56:30 -0000       1.43
+++ Makefile    8 Mar 2011 22:41:37 -0000
@@ -4,7 +4,7 @@ COMMENT =       open source web browser engine
 
 DISTNAME =     webkit-1.2.7
 EPOCH =                0
-REVISION =     0
+REVISION =     1
 CATEGORIES =   www
 
 HOMEPAGE =     http://webkitgtk.org/
Index: patches/patch-WebCore_ChangeLog
===================================================================
RCS file: patches/patch-WebCore_ChangeLog
diff -N patches/patch-WebCore_ChangeLog
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebCore_ChangeLog     8 Mar 2011 22:58:33 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+--- WebCore/ChangeLog.orig     Tue Mar  8 16:16:50 2011
++++ WebCore/ChangeLog  Tue Mar  8 16:10:10 2011
+@@ -1,3 +1,19 @@
++2011-03-08  Marco Peereboom   <marco@peereboom.u>
++
++        Reviewed no one yet
++
++        Backport code to enable/disable dns prefetching.
++        DNS prefetching is enabled by default.
++        https://bugs.webkit.org/show_bug.cgi?id=28825
++
++        * dom/Document.cpp:
++        (WebCore::Document::initDNSPrefetch): Check 
settings->dnsPrefetchingEnabled().
++        * page/Settings.cpp:
++        (WebCore::Settings::Settings): Set m_dnsPrefetchingEnabled to true.
++        (WebCore::Settings::setDNSPrefetchingEnabled): Added. Set 
m_dnsPrefetchingEnabled.
++        * page/Settings.h:
++        (WebCore::Settings::dnsPrefetchingEnabled): Added. Return 
m_dnsPrefetchingEnabled.
++
+ 2010-06-21  Philippe Normand  <pnorm...@igalia.com>
+ 
+         Reviewed by Xan Lopez.
Index: patches/patch-WebCore_dom_Document_cpp
===================================================================
RCS file: patches/patch-WebCore_dom_Document_cpp
diff -N patches/patch-WebCore_dom_Document_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebCore_dom_Document_cpp      8 Mar 2011 22:58:25 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+--- WebCore/dom/Document.cpp.orig      Fri Sep 10 08:20:33 2010
++++ WebCore/dom/Document.cpp   Tue Mar  8 10:16:45 2011
+@@ -4639,8 +4639,10 @@ HTMLCanvasElement* Document::getCSSCanvasElement(const
+ 
+ void Document::initDNSPrefetch()
+ {
++    Settings* settings = this->settings();
++
+     m_haveExplicitlyDisabledDNSPrefetch = false;
+-    m_isDNSPrefetchEnabled = securityOrigin()->protocol() == "http";
++    m_isDNSPrefetchEnabled = settings && settings->dnsPrefetchingEnabled() && 
securityOrigin()->protocol() == "http";
+ 
+     // Inherit DNS prefetch opt-out from parent frame    
+     if (Document* parent = parentDocument()) {
Index: patches/patch-WebCore_page_Settings_cpp
===================================================================
RCS file: patches/patch-WebCore_page_Settings_cpp
diff -N patches/patch-WebCore_page_Settings_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebCore_page_Settings_cpp     8 Mar 2011 22:58:31 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+--- WebCore/page/Settings.cpp.orig     Fri Sep 10 08:20:33 2010
++++ WebCore/page/Settings.cpp  Tue Mar  8 15:48:38 2011
+@@ -128,6 +128,7 @@ Settings::Settings(Page* page)
+     , m_webGLEnabled(false)
+     , m_loadDeferringEnabled(true)
+     , m_tiledBackingStoreEnabled(false)
++    , m_dnsPrefetchingEnabled(true)
+ {
+     // A Frame may not have been created yet, so we initialize the 
AtomicString 
+     // hash before trying to use it.
+@@ -509,6 +510,11 @@ void Settings::setShouldPaintNativeControls(bool shoul
+ void Settings::setUsesEncodingDetector(bool usesEncodingDetector)
+ {
+     m_usesEncodingDetector = usesEncodingDetector;
++}
++
++void Settings::setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)
++{
++    m_dnsPrefetchingEnabled = dnsPrefetchingEnabled;
+ }
+ 
+ void Settings::setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)
Index: patches/patch-WebCore_page_Settings_h
===================================================================
RCS file: patches/patch-WebCore_page_Settings_h
diff -N patches/patch-WebCore_page_Settings_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebCore_page_Settings_h       8 Mar 2011 22:58:28 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+--- WebCore/page/Settings.h.orig       Fri Sep 10 08:20:33 2010
++++ WebCore/page/Settings.h    Tue Mar  8 10:16:45 2011
+@@ -158,6 +158,9 @@ namespace WebCore {
+         void setUsesEncodingDetector(bool);
+         bool usesEncodingDetector() const { return m_usesEncodingDetector; }
+ 
++      void setDNSPrefetchingEnabled(bool);
++      bool dnsPrefetchingEnabled() const { return m_dnsPrefetchingEnabled; }
++
+         void setUserStyleSheetLocation(const KURL&);
+         const KURL& userStyleSheetLocation() const { return 
m_userStyleSheetLocation; }
+ 
+@@ -376,6 +379,7 @@ namespace WebCore {
+         bool m_webGLEnabled : 1;
+         bool m_loadDeferringEnabled : 1;
+         bool m_tiledBackingStoreEnabled : 1;
++      bool m_dnsPrefetchingEnabled : 1;
+ 
+ #if USE(SAFARI_THEME)
+         static bool gShouldPaintNativeControls;
Index: patches/patch-WebKit_gtk_ChangeLog
===================================================================
RCS file: patches/patch-WebKit_gtk_ChangeLog
diff -N patches/patch-WebKit_gtk_ChangeLog
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebKit_gtk_ChangeLog  8 Mar 2011 22:58:23 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+--- WebKit/gtk/ChangeLog.orig  Tue Mar  8 16:17:18 2011
++++ WebKit/gtk/ChangeLog       Tue Mar  8 16:14:29 2011
+@@ -1,3 +1,20 @@
++2011-03-08  Marco Peereboom  <ma...@peereboom.us>
++
++        Reviewed no one yet
++
++        Provide a knob to enable/disable DNS prefetching.
++        DNS prefetching is enabled by default.
++        https://bugs.webkit.org/show_bug.cgi?id=28825
++
++        * WebKit/gtk/webkit/webkitwebsettings.cpp:
++        (webkit_web_settings_class_init):
++        (webkit_web_settings_set_property):
++        (webkit_web_settings_get_property):
++        (webkit_web_settings_copy):
++        * webkit/webkitwebview.cpp:
++        (webkit_web_view_update_settings):
++        (webkit_web_view_settings_notify):
++
+ 2010-06-15  Xan Lopez  <xlo...@igalia.com>
+ 
+         Reviewed by Gustavo Noronha.
Index: patches/patch-WebKit_gtk_webkit_webkitwebsettings_cpp
===================================================================
RCS file: patches/patch-WebKit_gtk_webkit_webkitwebsettings_cpp
diff -N patches/patch-WebKit_gtk_webkit_webkitwebsettings_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebKit_gtk_webkit_webkitwebsettings_cpp       8 Mar 2011 
22:58:17 -0000
@@ -0,0 +1,71 @@
+$OpenBSD$
+--- WebKit/gtk/webkit/webkitwebsettings.cpp.orig       Tue Mar  8 11:35:14 2011
++++ WebKit/gtk/webkit/webkitwebsettings.cpp    Tue Mar  8 16:40:24 2011
+@@ -108,6 +108,7 @@ struct _WebKitWebSettingsPrivate {
+     gboolean enable_page_cache;
+     gboolean auto_resize_window;
+     gboolean enable_java_applet;
++    gboolean dns_prefetch;
+ };
+ 
+ #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) 
(G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, 
WebKitWebSettingsPrivate))
+@@ -157,7 +158,8 @@ enum {
+     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
+     PROP_ENABLE_PAGE_CACHE,
+     PROP_AUTO_RESIZE_WINDOW,
+-    PROP_ENABLE_JAVA_APPLET
++    PROP_ENABLE_JAVA_APPLET,
++    PROP_DNS_PREFETCH
+ };
+ 
+ // Create a default user agent string
+@@ -857,6 +859,21 @@ static void webkit_web_settings_class_init(WebKitWebSe
+                                                          TRUE,
+                                                          flags));
+ 
++    /**
++    * WebKitWebSettings:dns-prefetch
++    *
++    * Whether webkit prefetches domain names
++    *
++    * Since: 1.2.8.
++    */
++    g_object_class_install_property(gobject_class,
++                                    PROP_DNS_PREFETCH,
++                                    g_param_spec_boolean("dns-prefetch",
++                                                         _("WebKit prefetches 
domain names"),
++                                                         _("Whether WebKit 
prefetches domain names"),
++                                                         TRUE,
++                                                         flags));
++
+     g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
+ }
+ 
+@@ -1077,6 +1094,9 @@ static void webkit_web_settings_set_property(GObject* 
+     case PROP_ENABLE_JAVA_APPLET:
+         priv->enable_java_applet = g_value_get_boolean(value);
+         break;
++    case PROP_DNS_PREFETCH:
++        priv->dns_prefetch = g_value_get_boolean(value);
++      break;
+     default:
+         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+         break;
+@@ -1218,6 +1238,9 @@ static void webkit_web_settings_get_property(GObject* 
+     case PROP_ENABLE_JAVA_APPLET:
+         g_value_set_boolean(value, priv->enable_java_applet);
+         break;
++    case PROP_DNS_PREFETCH:
++        g_value_set_boolean(value, priv->dns_prefetch);
++      break;
+     default:
+         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+         break;
+@@ -1291,6 +1314,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebS
+                  "enable-page-cache", priv->enable_page_cache,
+                  "auto-resize-window", priv->auto_resize_window,
+                  "enable-java-applet", priv->enable_java_applet,
++                 "dns-prefetch", priv->dns_prefetch,
+                  NULL));
+ 
+     return copy;
Index: patches/patch-WebKit_gtk_webkit_webkitwebview_cpp
===================================================================
RCS file: patches/patch-WebKit_gtk_webkit_webkitwebview_cpp
diff -N patches/patch-WebKit_gtk_webkit_webkitwebview_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-WebKit_gtk_webkit_webkitwebview_cpp   8 Mar 2011 22:58:20 
-0000
@@ -0,0 +1,37 @@
+$OpenBSD$
+--- WebKit/gtk/webkit/webkitwebview.cpp.orig   Tue Mar  8 11:29:41 2011
++++ WebKit/gtk/webkit/webkitwebview.cpp        Tue Mar  8 12:20:10 2011
+@@ -2662,7 +2662,7 @@ static void webkit_web_view_update_settings(WebKitWebV
+         javaScriptCanAccessClipboard, enableOfflineWebAppCache,
+         enableUniversalAccessFromFileURI, enableFileAccessFromFileURI,
+         enableDOMPaste, tabKeyCyclesThroughElements,
+-        enableSiteSpecificQuirks, usePageCache, enableJavaApplet;
++        enableSiteSpecificQuirks, usePageCache, enableJavaApplet, dnsPrefetch;
+ 
+     WebKitEditingBehavior editingBehavior;
+ 
+@@ -2699,6 +2699,7 @@ static void webkit_web_view_update_settings(WebKitWebV
+                  "enable-site-specific-quirks", &enableSiteSpecificQuirks,
+                  "enable-page-cache", &usePageCache,
+                  "enable-java-applet", &enableJavaApplet,
++                 "dns-prefetch", &dnsPrefetch,
+                  NULL);
+ 
+     settings->setDefaultTextEncodingName(defaultEncoding);
+@@ -2734,6 +2735,7 @@ static void webkit_web_view_update_settings(WebKitWebV
+     settings->setNeedsSiteSpecificQuirks(enableSiteSpecificQuirks);
+     settings->setUsesPageCache(usePageCache);
+     settings->setJavaEnabled(enableJavaApplet);
++    settings->setDNSPrefetchingEnabled(dnsPrefetch);
+ 
+     Page* page = core(webView);
+     if (page)
+@@ -2845,6 +2847,8 @@ static void webkit_web_view_settings_notify(WebKitWebS
+         settings->setUsesPageCache(g_value_get_boolean(&value));
+     else if (name == g_intern_string("enable-java-applet"))
+         settings->setJavaEnabled(g_value_get_boolean(&value));
++    else if (name == g_intern_string("dns-prefetch"))
++        settings->setDNSPrefetchingEnabled(g_value_get_boolean(&value));
+     else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), 
name))
+         g_warning("Unexpected setting '%s'", name);
+     g_value_unset(&value);

Reply via email to