Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:28:09+00:00 2026-06-13T07:28:09+00:00

I’m in need of some CSS for a WordPress plugin which are dynamic and

  • 0

I’m in need of some CSS for a WordPress plugin which are dynamic and would like to know what is the best or the most common method. I’m currently using method two but have problems with IE9. So I thought there could be a better solution for dynamic CSS and came up with these:

1.) include a style block with the wp_head hook

Pro:

  • No extra server request

Contra:

  • Depending on the size a lot data on each page
  • not so pretty
  • not cacheable

2.) Use admin_url('admin-ajax.php?action=my_css') in a link tag

Pro:

  • create CSS on-the-fly (and cache it with Transient API)
  • uses wp_enqueue_style
  • cacheable with expire headers

Contra

  • requires to load wp-load.php
  • doesn’t work on IE9 (why?)

3.) create a CSS file on changes

Pro

  • fast
  • no need to load the whole WordPress (wp-load.php)

Contra

  • not really dynamic
  • require write rules for certain folders
  • possible out of date or missing cause of script issues or missing permissions

I don’t like method one cause the style is not required on every page and method two doesn’t work on IE9.

Should I go with the third one or are the any disadvantages with it?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:28:10+00:00Added an answer on June 13, 2026 at 7:28 am

    You are somewhat limited with PHP not having a built-in persistent cache. If you can guarantee that you will have memcached, APC, or even file write access, then you can use any of these methods to cache your CSS, and retrieve it using a key. You would not need to use wp-load.php to do so, thus your performance would be improved over having to load all the plugins, etc.

    That said, your dynamic CSS should work in IE9 assuming you set header('Content-type: text/css'); before you output the CSS, per the Microsoft article MIME-Handling Change: text/css.

    All that said, you could try a hybrid approach of #1 and #2 – it sounds like #3 is out if you can’g guarantee that you have file write permissions. To implement, just detect the user-agent of the requesting browser, and set up a single function to output your CSS. If it is not IE9, you can include the stylesheet using admin_url('admin-ajax.php?action=my_css') and call your output from the hooked function, and if it is IE9 you can include the stylesheet in the header by calling the function from a hook to wp_head. This way you are able to cache the CSS for most clients, and work around for IE – your cons about page size, etc are valid… but it’s IE9.

    As long as you are able to cache the CSS per client, then you are typically looking at only one extra request to wp-load.php which shouldn’t be too great of a performance hit.

    You can check for IE9 using if (false!==strpos('MSIE 9;', $_SERVER['HTTP_USER_AGENT']))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.