WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#9286 closed feature request (wontfix)

Using HTML <base> or links from site root can trim down page size

Reported by: jidanni Owned by:
Milestone: Priority: lowest
Severity: trivial Version: 2.7.1
Component: Permalinks Keywords:
Focuses: Cc:

Description

Gentlemen, I have achieved big savings in the sizes of many pages by
using the same techniques MediaWiki does, mainly not repeating the
whole site name over and over in each link.
http://www.w3.org/TR/html401/struct/links.html#h-12.4

Here's the Makefile I used

i=http://abj.jidanni.org
j=$i/articles/index.php/
big.html:
	wget $j -O $@
from_root.html:big.html
	perl -pwle 's@$i@@g' $? >$@
using_base.html:big.html
	perl -pwle 's@$j@@g;m@</head>@&&print "<base href=\"$j\" />"' $? >$@
wc:big.html from_root.html using_base.html
	$@ -lc $?|sed /total$$/d

which gives

$ make wc
wc -lc big.html from_root.html using_base.html|sed /total$/d
   81  8884 big.html
   81  7454 from_root.html
   82  6339 using_base.html

I would like to especially draw your attention to using_base.html,
though a little bolder than MediaWiki by using <base>, we nonetheless
have lopped off a whole quarter of the bytes of this already diet page
(from my mom's blog, which I created.)

Furthermore, we find we in fact leave the link to the <form> undisturbed,
quelling some worries... Anyway, to actually get these savings, the
core code would need to be enhanced (perhaps allowing using <base> as
an option one can opt-out of), and not of course just running this
Makefile.

I checked in firefox, and even the feed URL works.

Anyway, I hope you'll leave this on the back burner as a long term opimization idea.

You must admit often we have complete grasp of many links and can make this optimization.

If worried about <form>, <meta>, and feed links, they can be left as absolute links.

My Makefile didn't especially put the <base> before all the <meta>s, but you could...

OK, well say theme developers want to use <base>,
but all the common tags probably have no switch one can throw just once somewhere to get them all not to still use absolute URLs.

Well OK, maybe putting a homebrew hook on bloginfo, but still no integrated approch available in the core...

Change History (6)

#1 @Viper007Bond
11 years ago

-1

If you're that concerned about filesize, then gzip.

If all content was WordPress generated, then <base> would be just fine as WordPress would know it's there. However all content is not WordPress generated -- much of it (namely post content and such) comes from the user who may or may not know about the <base> tag and it's setting. If they put a relative URL in their post, it could easily be broken and not go where they expected it to go.

Not to mention I believe (but am not sure) that absolute URLs are recommended for SEO purposes.

#2 @jidanni
11 years ago

In fact those people who relative link are in trouble already:
http://codex.wordpress.org/Linking_Posts_Pages_and_Categories#Relative_Link_Examples

(gzip: not relevant to this issue. P.S., Whose webhost doesn't use it
automatically already?)

Even on www.google.com's homepage, we find <form action="/search...>

As far as MediaWiki, well, they mopped up the last waste in
https://bugzilla.wikimedia.org/show_bug.cgi?id=17538

So we see the big players link from the site root at least.

Anyway, something to look into for the long term.

#3 @jidanni
11 years ago

  • Cc jidanni@… added

#4 @DD32
11 years ago

  • Component changed from Optimization to Permalinks
  • Resolution set to wontfix
  • Status changed from new to closed
  • Type changed from enhancement to feature request

gzip: not relevant to this issue

It is relevant, Using relative instead of Absolute links has the main advantage of smaller filesize to download, Gzip nullifies that advantage, as the filesize is smaller regardless (It might be a few extra bytes larger than a compressed relative link document though..)

Those who link from the site root are also generally those who's pages are accessable by multiple domains, Google's pages for example can be reached from over a 150 different domains, its the same page, its not like they have a different page for each domain.

If a user wants their theme to link from the site root, theres filters that can be used for that. Relative links do not work well at all anywhere within applications which use mod_rewrite and slashes in the url's, it gets too confusing, and when a user changes their permalink structure, it ends up in more painful places.

There's already enough people with relative link issues: http://core.trac.wordpress.org/search?q=relative+links&noquickjump=1&ticket=on most of them just dont understand what a relative link is, or why its not working for them, adding a <base> would only help to add to their confusion.

#5 @jidanni
11 years ago

OK, you are right about gzip. I see.
But only over the phone line: the page is still bulkier in the
browser, etc.

I'll try /root linking in my theme.

#6 @Viper007Bond
11 years ago

If you compare the gzipped versions of your absolute and relative URL test cases, you'll likely find the difference is literally only a couple bytes.

Note: See TracTickets for help on using tickets.