Performance: Form field types
MEDIUM IMPACT
Form field types impact page load speed and interaction responsiveness by controlling input validation and rendering complexity.
from flask_wtf import FlaskForm from wtforms.fields.html5 import EmailField class UserForm(FlaskForm): email = EmailField('Email') # Using EmailField enables native browser validation
from flask_wtf import FlaskForm from wtforms import StringField class UserForm(FlaskForm): email = StringField('Email') # Using generic StringField for email input
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Generic StringField for email | Low (1 input node) | 1 reflow on input validation | Medium paint cost due to JS validation UI | [X] Bad |
| EmailField (HTML5 email input) | Low (1 input node) | No extra reflows on validation | Low paint cost with native validation UI | [OK] Good |
| StringField for numeric input | Low (1 input node) | 1 reflow on JS validation | Medium paint cost due to custom validation UI | [X] Bad |
| IntegerField (HTML5 number input) | Low (1 input node) | No extra reflows on validation | Low paint cost with native numeric keyboard | [OK] Good |