Hello my question is if using a jQuery plugin to scale/resize images on the fly, will be faster than doing it through开发者_C百科 a PHP function or TimThumb.
This came into my mind because jQuery is a user-side and PHP is server side.
You can't compare them, both have pros and cons.
I would go for timthumb, since it has some advanced options on cropping + it stores a cached version of the resized image which would save you bandwidth in the future plus speed up your website loading time.
Also think about the small amount of people that have javascript disabled, timthumb will also provide them resized images while a jQuery plugin wouldn't.
GO for timthumb ;)
Both are interpreted languages so I guess the speed would be pretty close. It will really depend on your requirements. In the first case you will be using the client's resources whereas in the second the server resources. For example if you just want to generate some thumbnails on the fly without posting to the server you could do it with javascript. But if you will make a request to the server then probably it would be better to do it on the server.
Uhm … You wouldn't need any jQuery Plugin to resize images client-side. Browsers can do that on their own, you just need to tell them to do so either via CSS or via "width" and "height" attributes of the <img> tag.
As for performance: Depending on the user's machine, their connection speed and dozens of other factors, performance may significantly improve if you serve them pre-resized images.
Rule of thumb (mind the pun!): If you can cache your resized images, it's usually worth to resize them server-side. You have to do the nitty gritty computation only once, afterwards, the images are neatly sitting in the cache and waiting for the client to come fetch them.
No more resizing, neither server nor client side! Everyone's happy.
Now, can I have a cookie?
精彩评论