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.
Issue fork page_to_pdf-3484180
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
Comment #3
andreastkdf commentedComment #4
andreastkdf commentedSee 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.
Comment #5
andreastkdf commentedComment #6
andreastkdf commentedComment #9
scott_euser commentedLooks good, thanks!