johnregan3/simple-custom-css — pull request #13 by dannyvankooten (2014-07-01 12:13:46+00:00)
Title: 70% less SQL queries for CSS requests. Don't load unnecessary code.

Hi John,

Great plugin, thanks a lot!

Been recommending this plugin to my clients for quite some time now but couldn't help but notice the late hooking on `template_redirect`, causing a lot of unnecessary SQL queries just to serve the CSS.

I made some changes which do not affect the plugin functionality any way but improves on the following aspect

- Split up code between admin, public and AJAX requests.
- Hook at `plugins_loaded`, which fires **before** the main WP query. This reduces the number of SQL queries by about 70% (down to just a handful for retrieving the options).
- Simplify the "query_var" logic. A simple `$_GET` check is sufficient.
- Use `add_query_arg` to generate the stylesheet URL.

A debugger or even the P3 Performance Plugin Profiler will show you the results of these changes right away.

Hope you have some time to test out the changes any time soon. :-)