Welcome to Virtual Pet List!

Wanting to join the rest of our members? Feel free to sign up today. Like what you see? Then join our community! You'll love it! Its free!

Sign Up
  1. virtual pet mascot

    Virtual Pets

    Welcome to the Virtual Pet list forum!
    We're a virtual pets and sim games community and the largest forum in our industry. We have a lot of virtual pet sites' owners and sim game owners that are quite active on our online community. Along with artists, writers and programmers that come here looking for work and games to work for. Our members who are artists sell art in our art marketplace and programmers are allowed to sell their scripts in the programming marketplace. We've been opened since 2011, however, we've owned our domain name since 2004 and since then we've grown and expanded quite nicely. What are you waiting for, why don't you join today?

    Our list of virtual pet sites and directory of sim games have a lot of games listed that you can try out and possibly enjoy. If you're still curious about a game to play, you can check out some of our game reviews that were written by some of our great contributors and our interviews with respective virtual pet site owners, sim game owners, artists, writers and programmers that have done work in this industry as a whole.

  2. Check out our latest guide on how to grow your user base!
    Paladore - Boopets - Icepets - Corepets open beta
    Virtual Pet Directory
    Are you looking for new virtual pet sites or sim games to play?

Coding problem, help needed

Discussion in 'Programming General' started by Hituro, Jun 1, 2012.

  1. Hituro
    Offline

    Hituro Approved Game Owner Pet Game Owner VPL Supporter VPL Member

    Reputations:
    10
    Joined:
    Feb 1, 2011
    Messages:
    1,416
    Likes Received:
    96
    Trophy Points:
    48
    Okay, I have a coding problem I just can't get my head around, so I thought I would throw it out there and see if anyone has any ideas.

    When you load a page on Grophland you may get one or more random events. Some of these events require complex CSS. Since they can appear on any page the CSS is in the main site CSS, taking up pointless room, so I want it out of there. However events are triggered by including a script (events.php) *after* the header file, so CSS for the page is already set. This means I can't remove the CSS to optional stylesheets.

    Now I can move generation of events to earlier in the process, before the header is sent, so I can use optional CSS. However not every page shows events. This means if I generate events before the rest of the page loads then they may not actually get displayed on that page, which could mean some important notification being missed. I don't want to go and change every page (out of hundreds) to pass some value saying they are, or are not, going to display events and messages, but I can't see how else to avoid generating the events on pages that won't show them.

    Any ideas?
  2. indysolo621
    Offline

    indysolo621 Member VPL Member

    Reputations:
    0
    Joined:
    Feb 27, 2011
    Messages:
    1,397
    Likes Received:
    59
    Trophy Points:
    48
    Can you not take the events css out of the header and have it only display if you do have a random event on the page?
  3. nobackseat
    Offline

    nobackseat Member VPL Member

    Reputations:
    0
    Joined:
    Jan 22, 2011
    Messages:
    508
    Likes Received:
    46
    Trophy Points:
    28
    Location:
    Florida
    Style tags can work in the body, it's not that big of a deal. If you must be politically correct then make the CSS inline and use an older DOCTYPE. Echo it in the same block as the HTML of the actual event itself. Every unnecessary byte adds up to quite a bit when it comes to mobile phones or your site's bandwidth.

    NBS
  4. Hituro
    Offline

    Hituro Approved Game Owner Pet Game Owner VPL Supporter VPL Member

    Reputations:
    10
    Joined:
    Feb 1, 2011
    Messages:
    1,416
    Likes Received:
    96
    Trophy Points:
    48
    That might be the best idea, can I do an inline style with an @import?
  5. Grotesque
    Offline

    Grotesque Approved Game Owner Pet Game Owner VPL Member

    Reputations:
    0
    Joined:
    Oct 17, 2011
    Messages:
    261
    Likes Received:
    75
    Trophy Points:
    0
    Bundle all your css-files to one, compress and timestamp/hash-mark it, thus the browser can do proper caching. You have PLENTY of whitespace and each single asset increases load time.

    This is how we do in our production enviroment:

    http://breepets.net/assets/application-aea34afe3f096fd5877b296b6875aa2e.css

    There are tools out for this kind of stuff. Luckily, Rails does this automagically for me. However, you might also take look at SASS

Share This Page