Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Advice For Organizing Code

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #167051
    Anonymous
    Inactive

    What tips and advice do you have regarding the organization of lots of JS, CSS, and HTML code and files? Especially when someone else will be reading and editing that code in the future.

    #167055
    nixnerd
    Participant

    Hmmm. Well, I would say the first thing is to code in a modular way. You want your code to be as reusable as possible. For example, build a sidebar in such a way that you can put anything you want in it. Give yourself options down the road. This will also make your code cleaner and there will be less of it.

    The easiest thing to do is start using PHP and SASS/SCSS. The real advantage here is that they will both allow you to modularize your HTML and CSS respectively. PHP includes and SASS imports are awesome. Sure, you could just have a million different style sheets. Or… you could do in-line styles. The problem is, having more than one style sheet is incurring additional load time because there will be unnecessary server calls. Using in-line styles almost COMPLETELY negates the entire purpose of CSS.

    When you use a preprocessor, your workflow is modular. But… the production code is not. SASS leverages Ruby to compile all your CSS together BEFORE it goes live. You also get some nice benefits like extended inheritance and variables. Super awesome.

    I would start with those. That’s where you’ll get the most bang for your organizational buck.

    *P.S. I would ask a real PHP guru how to handle a lot of includes. I think at a certain point, you need to compile it all together in straight up HTML. From a maintainability standpoint, that’s absurd but again, I’m not sure. PHP includes are DEFINITELY beneficial during development because you can keep everything really clean. But again, I think it takes more time for the server to build each page and can cause speed issues.

    #167068
    __
    Participant

    how to handle a lot of includes. I think at a certain point, you need to compile it all together in straight up HTML. From a maintainability standpoint, that’s absurd but again, I’m not sure.

    Once your site is pretty much finalized, you can start caching (e.g., APC or Memcached). But even before that, it would take a lot of includes to cause any really noticeable issues.

    The worst performance issues with PHP scripts are usually external calls (mainly Databases) and poorly designed loops. Or both of those at once… that’s actually a very common mistake.

    #167088
    nixnerd
    Participant

    Ok, yeah I knew ton of database calls is no bueno. But, you should be good to use PHP for includes. That will help you abstract things enough to keep things tidy.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.