Create and link an external css file? (4 posts)

  1. ashtonej
    Posted 2 years ago #

    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.

  2. Drew Westcott
    Posted 2 years ago #

    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?

    The Campervan Coder

  3. Andrew
    Moderator of Puppies
    Posted 2 years ago #

  4. ashtonej
    Posted 2 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Topic