Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK 4 - Reduce unused JavaScript - no.2 #1503

Open
essafaizall opened this issue Mar 12, 2025 · 0 comments
Open

TASK 4 - Reduce unused JavaScript - no.2 #1503

essafaizall opened this issue Mar 12, 2025 · 0 comments
Assignees
Labels
SEO SEO Request for website 💪🏼 User Request L1 Requested by User

Comments

@essafaizall
Copy link

essafaizall commented Mar 12, 2025

Image

Suggestions to check & fix:

  1. Reduce recorded events (skip canvas, limit scroll/input tracking)
  2. Use rrweb-lite (rrweb-snapshot) instead of full rrweb
  3. Lazy load rrweb when needed
  4. Ensure defer is set

Follow this recommendation:

  1. Configure rrweb to Capture Only Essential Events - If you don’t need full session replay, limit the data collection:
import { record } from 'rrweb';

record({
  recordCanvas: false, // Disable recording of canvas elements (reduces size)
  emit: (event) => {
    if (event.type === 4) return; // Skip large Mutation events (optional)
  },
  ignoreClass: 'no-replay', // Exclude elements with this class from being recorded
  sampling: {
    mousemove: 100, // Reduce mousemove event frequency
    scroll: 150, // Reduce scroll event frequency
    input: 'last', // Capture only the last input value instead of every keystroke
  },
});

Inspect and optimise this way:

  • Disable recordCanvas (biggest performance saver)
  • Exclude unnecessary elements with .no-replay class
  • Reduce frequency of mouse, scroll & input tracking
  1. Use rrweb-lite Instead of Full rrweb - If you don’t need full replay functionality, switch to rrweb-snapshot (lighter version). npm install rrweb-snapshot

Then, replace:
import { record } from 'rrweb';

with this:
import { snapshot } from 'rrweb-snapshot';
This removes event playback, keeping only snapshot functionality.

  1. Instead of loading rrweb.js on every page, load it only when needed.
    For example: Lazy load it when user starts a session:
if (userWantsReplay) {
  import('rrweb').then(({ record }) => {
    record({ ignoreClass: 'no-replay' });
  });
}

JavaScript is only loaded when required.

  1. Defer rrweb Loading - Ensure rrweb.js does not block page rendering, like this:

<script src="https://aw-fulfilment.co.uk/assets/rrweb-fc9e57ce.js" defer></script>

@github-project-automation github-project-automation bot moved this to Backlog in Aiku Mar 12, 2025
@inikoo inikoo added this to the SEO milestone Mar 12, 2025
@inikoo inikoo added SEO SEO Request for website 💪🏼 User Request L1 Requested by User labels Mar 12, 2025
@dandiAW dandiAW self-assigned this Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SEO SEO Request for website 💪🏼 User Request L1 Requested by User
Projects
None yet
Development

No branches or pull requests

3 participants