Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp:image or img

Does asp:Image tag perform faster than normal HTML img tag?

I have 20 images to show on a web page (tiny images) and I have no idea which one to use.

like image 359
Gayan Avatar asked Mar 21 '26 04:03

Gayan


1 Answers

On server-side

HTML elements in usual use (without setting runat="server" on them) are always faster compared to server-side counterparts, because they don't execute any additional server-side logic or consume other resources. They also don't add anything to page's view state.

On client-side

Simple server-side controls (those that translate to a single HTML element) are no different to normal HTML elements. But complex server-side controls (like calendar) are complex in terms of HTML element quantity thus require some additional browser resources. But making the same thing/functionality with usual HTML would create more or less similar results. So we can assume on the client-side speed is the same.

Verdict

Use server side controls only when you need to add some server-side processing to it. If not, rather use plain-old-HTML-controls. They will be processed faster on the server, will not add anything to view state and will work with the same speed on the client as their server-side counterparts.

This is true for any HTML element that has a server-side equivalent (like img that has asp:Image on the server side). When there's no client-side equivalent (like calendar) you have to of course use server side controls or use some client-side library that provides such functionality (jQuery has a date picker for instance). But you have to know Asp.net processing quite well to combine the two effectively.

like image 80
Robert Koritnik Avatar answered Mar 22 '26 20:03

Robert Koritnik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!