Commit 6728d12
authored
Add a
* Add a `slimDOM` option to strip out unnecessary parts of the DOM in terms of replay
- <script> tags in the <head> take up unnecessary storage space and are often injected semi randomly to become a source of unnecessary variation between recordings of the same thing
- comment tags can be stripped out without affecting display
- future: this option could also turn on more aggressive stripping, e.g. elements that are hidden by CSS (assuming we can handle them becoming visible after mutation events)
* Mark nodes ignored due to slimDOM option, so that they can also be ignored by the mutation observer in rrweb
* Introducing the `ignored` attribute violates the `serializedNodeWithId` type
* slimDOM: Strip out whitespace nodes from <head> element as they have no effect but take up space
- these would otherwise have to be merged after <script> elements are removed; for statcounter usecase, removing
<script> elements is no good if there is still a trace of their presence due to the white space (and hence a variant <head> node is still produced)
- I explored a more radical stripping of all white space nodes, but there is a problem if parent node is <pre> or otherwise rendered with `white-space: pre` and similar.
detecting applied styles with getComputedStyle would be very expensive (I haven't measured it though)
* Export IGNORED_NODE as a constant instead of relying on the hard-to-grok `-2`
* Remove <link rel=preload as=script> which are similarly as useless as <script> tags
* Make slimDOM configurable with the expecations that `slimDOMOptions: true` will only enable non-destructive options (so not all options may be turned on)
* Expand slimDOM to add options to remove more elements from the <head> that should not be necessary in the replayer contextslimDOM option to strip out unnecessary parts of the DOM (#36)1 parent fd285ed commit 6728d12
3 files changed
+139
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
323 | 326 | | |
324 | 327 | | |
325 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
326 | 406 | | |
327 | 407 | | |
328 | 408 | | |
| |||
331 | 411 | | |
332 | 412 | | |
333 | 413 | | |
| 414 | + | |
334 | 415 | | |
| 416 | + | |
335 | 417 | | |
336 | 418 | | |
337 | 419 | | |
| |||
346 | 428 | | |
347 | 429 | | |
348 | 430 | | |
| 431 | + | |
349 | 432 | | |
350 | 433 | | |
351 | 434 | | |
352 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
353 | 443 | | |
354 | 444 | | |
355 | 445 | | |
356 | 446 | | |
357 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
358 | 451 | | |
359 | 452 | | |
360 | 453 | | |
| |||
367 | 460 | | |
368 | 461 | | |
369 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
370 | 471 | | |
371 | 472 | | |
372 | 473 | | |
| |||
376 | 477 | | |
377 | 478 | | |
378 | 479 | | |
| 480 | + | |
379 | 481 | | |
| 482 | + | |
380 | 483 | | |
381 | 484 | | |
382 | 485 | | |
| |||
391 | 494 | | |
392 | 495 | | |
393 | 496 | | |
| 497 | + | |
394 | 498 | | |
395 | 499 | | |
396 | 500 | | |
| |||
416 | 520 | | |
417 | 521 | | |
418 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
419 | 542 | | |
420 | 543 | | |
421 | 544 | | |
| |||
425 | 548 | | |
426 | 549 | | |
427 | 550 | | |
| 551 | + | |
428 | 552 | | |
429 | 553 | | |
430 | 554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
0 commit comments