Performance: URLSearchParams for query strings
LOW IMPACT
This affects how query strings are parsed and serialized, impacting server-side processing speed and memory usage.
const query = 'name=alice&age=30'; const params = new URLSearchParams(query); const name = params.get('name'); const age = params.get('age');
const query = 'name=alice&age=30'; const params = {}; query.split('&').forEach(pair => { const [key, value] = pair.split('='); params[key] = decodeURIComponent(value); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual string split and decode | 0 | 0 | 0 | [X] Bad |
| URLSearchParams native API | 0 | 0 | 0 | [OK] Good |