Six common code problems—and how they affect people

Not all code needs the same treatment

KEEP

Essential, useful code

Navigation, authentication, accessible forms and meaningful functions should remain. Improve implementation if the cost is excessive.

LOAD WHEN NEEDED

Useful but noncritical features

Some maps, video players, rich widgets or support tools may load after visitor interaction or when their section becomes relevant.

REPLACE OR REMOVE

Duplicate or unnecessary code

Old trackers, unused sliders and overlapping plugins may have no clear purpose. Verify usage and dependencies before removal.

A caution about async and defer: they are useful script-loading options, but they are not interchangeable for code that depends on execution order. Measure, test and preserve required behavior.

How do we find and test code problems?

01

List loaded resources

Use browser developer tools to see scripts, stylesheets, network requests, origins, transfer size and timing.

02

Identify responsibility

Connect resources with site features, plugins, tags, business goals and maintainers. Flag code with no confirmed purpose.

03

Measure execution costs

Profile slow interactions, main-thread tasks, network waterfalls and rendering behavior under representative conditions.

04

Choose a limited change

Remove a duplicate integration, split an unnecessary bundle or modify loading order where technically appropriate.

05

Test essential journeys

Confirm navigation, forms, consent, checkout or booking still work with mouse, keyboard and mobile devices.

06

Compare and document

Record before-and-after evidence, affected pages, any regressions and the plan for updating or monitoring dependencies.

Trusted technical references

See MDN's HTML script documentation, web.dev's third-party script loading guidance, and web.dev's guide to long JavaScript tasks. Each supports a specific technical question; none replaces testing your own site.

How does script optimization become part of the Optimization Plan?

The issue passes through Website Audit, Optimization Plan, Implementation, Validation and Monitoring.