SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Database Driven vs. JavaScript Driven

    I'm currently working on a portfolio site with PHP and MySQL. I'm at the point now where I'm ready to decide how my application will serve up the portfolio pieces from my database.

    I was wondering if it is better to postback to the server everytime they load a new piece or if I should load my whole database into a multi-dimensional javascript array and work with it that way.

    I was hoping to cut down on the bandwidth by using an all flash application but I ended up going with the HTML approach. So I was thinking of saving bandwidth by running off of a JavaScript array.

    I'd like to find the most efficient programming solution.

    I was a bit apprehensive about asking this question because it looks like a no-brainer but I figured some of you may have experience with this type of functionaity and some advice. Thanks.

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume you are talking about a large mutli page portfolio? If so I would recommend the "back to db per page" idea .. its really not that weighty on the server (also depends on your traffic)

    I guess it would also depend on how heavy that pages would be if you loaded everything into a javascript array .... and what you are loading into that array. If its image objects I say absolutely not, if nothing more than urls of images it might be ok.. but seeing as how a preload on the images would be a major factor on your portfolios performance NOT loading the images would turn your pages into mud!

    I only say this because you can overload a users machine with a page ..... Ive actually "melted the page" with a form I did a few years ago that was uber long! Remember .... whatever you load into a web page loads into the memory of the machine the customer is using ..... and you can crash their browser if you try to load too much..

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent feedback, thank you. A JavaScript array is definitely NOT the way to go for this large project.

    I mentioned before how I was using a Flash application in the beginning for this project and I did so with XML. After updating my database I had a PHP script update/write an XML file and then I would just use that in Flash instead of hitting the database everytime I need to load a portfolio piece.

    Could this work the same way in PHP? Could I use an XML file instead of hitting my database everytime? Would it save me a bit of bandwidth and if so how much? Is PHP used to parse XML like this or am I doing something out of the norm?

    Any help would be greatly appreciated, thanks.

  4. #4
    Non-Member
    Join Date
    Nov 2003
    Location
    here
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could create the XML every time the database is updated and just load from XML, that would save you a lot of bandwidth and database queries. You could also generate HTML instead of XML some people do this if they have a heavy database.

    Personally I think the bandwidth consumed in doing database queries is negligible unless its an absolutely massive database transferring binary images around etc. etc... most bandwidth can be saved in caching images, optimising images and writing clean code and thats where you should concentrate your optimisation efforts.

  5. #5
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The JavaScript solution is very fast once uploaded, but if the data is too big it may take a lot of time in the beginning of download.

    And, still there are some browsers that are not JavaScript enabled


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •