An optimized website is not only about fewer tags, styles or plugins, I also believe that resources on the server side need to be optimized for better performance.
So the use of a if
can help to execute several data that can be executed in one or by elseif
executing another different script.
if($var === 'a' || $var === 'b' || $var === 'c'){
//Ejecutar
}elseif($var1 === 'd'){
//Ejecutar
} else {
//Default
}
And in the use of a switch
it is executed in a very elegant way although it has its drawbacks, for example having to add a new one switch
when the variable is different, for example:
switch ($var) {
case 'a':
# code...
break;
case 'b':
# code...
break;
case 'c':
# code...
break;
default:
# code...
break;
}
switch ($var1) {
case 'd':
# code...
break;
}
Both uses seem simple, but which one occupies more resources, rather than an opinion, is an important issue that I think should be taken into account for applications with much more performance.