WordPress.org

Support

Support » Themes and Templates » Create and link an external css file?

Create and link an external css file?

  • My pages need some optimizing. Each page has a huge chunk of inline css: template, plugins, etc.

    Is there any way that I can create an external css file and link it to the pages? Or is there a plugin that will do this. I tried WP minify but 1) It looks pretty out of date and 2) I tried it and it messed up my slideshow javascript.

    Any advice would be deeply appreciate as this combined chunk of inline CSS must contain about a 1,000 lines of code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi ashtonej,

    Where has the inline CSS come from?

    It should be very possible to move it to an external file, either in the current theme, or a child theme, to make sure it continues past any wordpress updates.

    You would just then need to create a <rel linkā€¦ in the header file of the theme to this new style sheet.

    Something like <link rel="stylesheet" type="text/css" media="all" href="[url to your new external style sheet]" />

    Can you provide a link to you site, so I can take a look at the current set up?

    Drew
    The Campervan Coder

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    Thanks for the tips.

    I tried enqueue and it messed up the page.

    In the end I tweaked the template style.php page.

    It was the culprit. I modified the code just before the css was sent to the page. It now saves the css file and serves it up via a <link rel

    Here’s hoping it doesn’t cause problems. I’ve put an exclusive lock on each write so it should be OK. There’s a chance that there may be timing issues but for the moment the risk is in nano seconds and traffic isn’t an issue (for now at least).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create and link an external css file?’ is closed to new replies.
Skip to toolbar