treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Linked Stylesheets vs. include(); ?

  • This is really more of a theoretical discussion, but is it better to use links to your css and js files, or to include them with php?
    Like this:
    <head>
    <link rel="stylesheet" href="./style.css">
    <script src="script.js"></script>
    </head>
    Versus this:
    <head>
    <style><?php include("./style.css"); ?></style>
    <script><?php include("./script.js"); ?></script>
    </head>
    I know that in the first one, you can take advantage of caching, but the second one is much less http requests. Do any of you have an opinion on this?




  • If your css/script is less than 4kb then you could use the php include to reduce requests otherwise just call it the normal way