I have a photo viewer page that I need to make work with varying numbers of photos without lots of intervention on my part. My plan is to autogenerate the HTML for things like thumbnails so that I can use one loop instead of copy-pasting a bunch of the same code.
So, I can do this with JavaScript or with PHP. As I understand it, PHP will be faster because it will be cached with everything already generated. Am I right about that? Are there advantages to using JS?
Thanks in advance!
you would be best off using php and a database or folder of images. PHP will allow google to index the images in image search, also php insures that all browsers view it correctly. Also if you have a large number of photos you would have to send all the data to the browser on load which would slow down the load time. Javascript can be effective for retrieving the next page of data via ajax or JSON, improve the user interface or doing complex interactions with the user, outside of that I wouldn’t recommend javascript for this task.