Problem/Motivation

Paged.js encounters an intermittent issue on Drupal sites when CSS and JS aggregation is enabled. Switching to the Gin theme, for example, can trigger the error under certain configurations. In these cases, enabling aggregation causes the page using paged.js to fail, with the following error in the console:

Uncaught (in promise) Error: item doesn't belong to list
    at Ee.remove (paged.polyfill.min.js:4:39947)
    at Tu.constructor.onRule (paged.polyfill.min.js:4:475590)
    at paged.polyfill.min.js:4:4186
    at Array.forEach (<anonymous>)
    at B.trigger (paged.polyfill.min.js:4:4157)
    at Object.enter (paged.polyfill.min.js:4:407411)
    ...

This error seems challenging to reproduce consistently across different Drupal installations, as some setups work fine while others encounter this issue. Due to this inconsistency, the only realistic solution is disabling preprocessing for paged.js to prevent the error. Performance-wise, this will have minimal/none impact as paged.js is only used on /pdf pages, viewed by editors only or the actual pdf generation service.

Proposed resolution

To avoid conflicts introduced by Drupal’s aggregation and minification processes, modify the libraries.yml configuration for paged.js to set preprocess: false. This adjustment instructs Drupal to load paged.js without preprocessing, reducing the likelihood of compatibility issues.

Remaining tasks

Update the library definition in .libraries.yml.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andreastkdf created an issue. See original summary.

andreastkdf’s picture

andreastkdf’s picture

See MR instructing Drupal to load paged.js without preprocessing.

This doesn't fix all issues, and AdvAgg (when stable for Drupal 10) could be a recommendation on the project page, for site admins to disable all aggregation on /pdf pages but it makes sense to have it disabled at least for the library we include with this module.

andreastkdf’s picture

Status: Active » Needs review
andreastkdf’s picture

Assigned: andreastkdf » scott_euser

scott_euser made their first commit to this issue’s fork.

scott_euser’s picture

Assigned: scott_euser » Unassigned
Status: Needs review » Fixed

Looks good, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.