combining CSS & Js into One File. (3 posts)

  1. kwmlr439
    Posted 3 years ago #

    I am a pretty savvy person when it comes to WP but got stuck on this one. There are plenty of plugins that can accomplish this but I rather do it manually. I have multiple CSS and Js files on my WP theme and I want to be able to generate a one files and make it as the main one.

    For example, for the CSS files I have a couple:

    [ Moderator note: please wrap code in backticks or use the code button. ]

    <link rel='stylesheet'   href='website.com/style1.css'
    <link rel='stylesheet'   href='website.com/style2.css'
    <link rel='stylesheet'   href='website.com/style3.css'
    <link rel='stylesheet'   href='website.com/style4.css'
    <link rel='stylesheet'   href='website.com/style5.css'

    How can I manually combine them to be like this:

    <link rel="stylesheet" href="website.com/style1,style2,style3,style4,style5.css">

    and then get ride of the one I have on the main page right now.

    Same goes for .Js files as well.

    There are plenty of tutorials but none of them is helpful. Thanks a lot for all your help and what you do.


  2. tcertain
    Posted 2 years ago #

    I have tried to do this also with wordpress plugin Total Cache and it caused my site to go down. Is there a manual way, which is theme-friendly and plugin friendly, to force a meld to at least 1 css file and 1 js file. All articles tell you to do this, and I know I can do this manually on a straight up html site, but not with wordpress involved. Its like everything is fighting each other to work. I know plugins are a problem, but holy cow, loading 10 css and js pages is ridiculous. I am at a loss how to make everything work together efficiently to make a speedy mobile friendly site.

  3. shamratdewan
    Posted 2 years ago #

    i would suggest to go in baby steps.. try to add couple of css togather then see how it goes then try to add more. and if i were you i would leave the js files as it is for various reasons. To speed up the site i suggest to have the best hosting resource possible and stay updated on Wp version. clean up database, using CDN to load css images and js also helps

Topic Closed

This topic has been closed to new replies.

About this Topic