Welcome to the Virtual Pet List Community

Wanting to join the rest of our members? Feel free to sign up today. It is completely free and one of the most positive communities on the web! Come and join the fun!

Join VPL Today!
  1. Virtual Pets

    Welcome to the Virtual Pet list forum!

    We're a Virtual Pets and Sim Games Community. We have a lot of Virtual Pet Sites Owners and Sim Games Owners that frequently visit, along with Artists, Writers and Programmers that come here looking for work and games to work for. Our Artists sell art in our Art Marketplace and Programmers are allowed to sell scripts in the Programming Marketplace. We've been opened since 2011 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 has a lot of Sim Games listed as well. You are more than welcome to check out our directory of sites and find a new game to play. If you're still curious about a game to play, you can check out some of our Game Reviews and Interviews with Coders, Artists, Writers and Game Owners of the industry.
  2. Have you read and commented on any of our Interviews or Reviews yet?
    Yes, it's true Teripets will not come back online
    Paladore - Boopets - Icepets
    Virtual Pet Directory
    join mycena cave!

Coding problem, help needed

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

  1. Hituro
    Offline

    Hituro VPL Supporter Pet Game Owner VPL Supporter VPL Member

    Joined:
    Feb 1, 2011
    Messages:
    1,386
    Likes Received:
    78
    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?
    join misticpets, support vpl
  2. indysolo621
    Offline

    indysolo621 Member VPL Member

    Joined:
    Feb 27, 2011
    Messages:
    1,395
    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

    Joined:
    Jan 22, 2011
    Messages:
    505
    Likes Received:
    43
    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 VPL Supporter Pet Game Owner VPL Supporter VPL Member

    Joined:
    Feb 1, 2011
    Messages:
    1,386
    Likes Received:
    78
    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

    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
Similar Threads
Forum Title Date
Programming General Coding Languages Feb 6, 2014
Programming General Modular Gaming For Coding Newbies? Jan 20, 2014
Programming General Live Streaming Coding Session Dec 30, 2013
Programming General Coding is boring sometimes? =( Apr 29, 2012
Programming General Question about coding I can't figure out... Mar 25, 2012
Programming General How important is Learning programming syntax and coding from scratch Feb 4, 2012
Programming General ||Looking to be taught coding for free..?|| Nov 10, 2011
Programming General PSD into CSS + HTML tutorial (website layout coding) Aug 1, 2011

Share This Page