WordPress Optimization – code hacks
-
For the fun and profit, I’m trying to improve (and speed-up) my WordPress blog. Beyond WP Super Cache I mean π
Because a browser (Internet Explorer, Firefox) can only make a limited number of HTTP requests simultaneous to a DNS host name, I added some to my website: img., css. and js. The plan is to load CSS files from css.mysite.tld and images from img.mysite.tld, you get the idea.
I have virtually no knowledge of the WordPress API, but for as far as I tried, this is a pain to do. Because you have to code-change every plug-in. For example:
* my Journalist theme: I added to functions.php:
add_filter('stylesheet_uri', 'change_css'); function change_css() { return "http://css.saotn.nl/wp-content/themes/journalist/style.css"; }
Unfortunately this does not work for added plug-ins, since
bloginfo('stylesheet_url')
is only for the current theme.* One of the other changes I had to make was in one of my plug-ins “Secure and Accessible PHP Contact Form”:
get_bloginfo('wpurl')
became
str_replace("saotn.nl", "js.saotn.nl", get_bloginfo('wpurl'))
(I know, my PHP skills aren’t that good).
* And in WP-Syntax:
$css_url = str_replace("saotn.nl", "css.saotn.nl",WP_PLUGIN_URL).'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
Is there a better way, with less code changes, to reduce HTTP requests? A general “CSS/JS URL Setting” in WordPress’ back-end would be nice π
- The topic ‘WordPress Optimization – code hacks’ is closed to new replies.