Docs / JavaScript / Load Scripts on User Interaction

Load Scripts on User Interaction

Many scripts are not required for the initial render. By delaying the load of such scripts, you can improve LCP and TTI and overall scores a lot.

Scripts used for tracking (like Google Analytics), chat widgets (Intercom, Crisp, Tawkto), etc are perfect examples for these.

By enabling "Load Scripts on User Interaction", the configured scripts are loaded and executed only when there is a user interaction like mouse movement, keyword input, scroll, mobile touch, etc. When there is no user interaction, there is a timeout of 10 seconds after which all scripts are loaded.

FlyingPress comes with a default list of keywords that are ideal for many websites. You can add your own scripts to the list.

Before Delaying Scripts

Not every script will be compatible with such delays. Test thoroughly after implementing.

Delaying ads and tracking scripts may or may not affect your revenue and data respectively.

Delaying All Scripts

To delay each and every script, add "script" as the keyword.

Delaying All Scripts from Theme

To delay all scripts from the theme, add "wp-content/themes" as the keyword.

Delaying All Scripts from Plugins

To delay all scripts from all plugins, add "wp-content/plugins" as the keyword.

Delaying All Scripts from a Particular Plugin

To delay all scripts from a particular plugin, add "wp-content/plugins/xxx" as the keyword. Where "xxx" is the plugin name.

For example, if the plugin is "Powerkit", the keyword should be "wp-content/plugins/powerkit".