trick to make relative URLs instead of full URI
-
It was really bothering me how a page full of links was wasting so many bytes on full absolute URI’s with the domain name, etc. when all it needed was a tidy relative URL. The front page alone is 4k bigger just because of all the full URIs on the tag cloud and views, etc.
ie. http://www.bbpress.org/forums/forum/plugins
vs. /forums/forum/plugins
(multiply that by a few hundred)
So it dawned on me just now that it’s fairly easy using filters to make all the urls relative. Just for safety, we don’t kick in the relative URLs until bbPress has gotten past the header section of the template. This makes sure that redirects, stylesheets, and javascript is handled properly.
function bb_relative_uri($r) {return "/forums/"; } // change forums to your path
function bb_relative_domain($r) {return ""; }
function bb_relative() {
add_filter( 'bb_get_option_domain','bb_relative_domain',255);
add_filter( 'bb_get_option_uri','bb_relative_uri',255);
} add_action('bb_head', 'bb_relative',255);.
In some cases, relative URLs actually makes Internet Explorer cache better so this may be helpful for subtle speedups too.
I haven’t discovered anything broken by this yet but be sure to let me know if you run into anything.
- You must be logged in to reply to this topic.