dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: Generate JS code or html tag ?

  1. #1
    Join Date
    Sep 2012
    Posts
    5

    Generate JS code or html tag ?

    Hi all,
    in your opinion what is better between generate JavaScript code or HTML tag from php script?
    I need to change image every 10 second and i have 2 ways to do this:
    1) the first is to create a long JS array and use the innerHTML every times i need to change images.
    2) the second is to create a looog HTML code with all images that i need, and always with JS change the position of images content div.

    So, what is the best way for the pc performans?
    Reguards!

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    1)

  3. #3
    Join Date
    Sep 2012
    Posts
    5
    hi, thanks for reaply, but can you explaine me why or link me somethings to read ? i can't find nothing ...

  4. #4
    Join Date
    Mar 2009
    Posts
    452
    using arrays has many advantages over creating individual html elements. arrays elements are easy to read and change their values, change their order etc...

    you can use a single image element and change the src using Javascript easily to display different images.

  5. #5
    Join Date
    Sep 2012
    Posts
    5
    Yes, i know that. My dubt is another. In wicth memory browsers put this different information ( JS code and HTML page ) ?
    I'm sure that JS code and his variables are in heap memory, but html pages where? Using a long array or scroll a long div have difference in prerformance? And this performance can be weighted with a non stop script running? I'm not looking for a easly code, i'm looking for a less expensive code.
    Thanks

  6. #6
    Join Date
    Mar 2009
    Posts
    452
    hmm..

    i think both of them are stored in heap but in different ways. its not easy to say which one is more or less expensive. depends on many other things. browser can cause major difference

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles