Knowledgebase

Reducing and Optimising Scripts Print

  • webdevelopment, performance, guide, howto, solution, zillionkinghost, hosting, support
  • 0

JavaScript cost.

WHY SCRIPTS COST MORE THAN THEIR SIZE

They must be downloaded, parsed, compiled and executed.

WHAT THAT MEANS

A script costs more than an image of the same size, particularly on modest devices.

WHAT TO DO

Ship less Split code, loading only what a page needs Defer anything not required immediately Remove unused dependencies

WHAT TO AUDIT

What is actually included in what you ship.

WHAT YOU WILL FIND

Libraries included for one function Duplicate dependencies Code for features long removed

WHAT TO QUESTION

Every dependency.

WHY

Each is downloaded, parsed and executed by every visitor.

WHAT TO PREFER

Platform features over libraries, where they suffice.

WHAT TO DEFER

Anything not needed for the initial view: analytics, chat widgets, secondary features.

WHAT TO BE CAREFUL WITH

Third-party scripts, which you do not control.

WHY

They can be slow, can fail, and can change without notice.

WHAT TO MEASURE

Time spent executing scripts, on a modest device.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot