@@ -306,6 +306,51 @@ window.Spicetify = {
306
306
Platform : { } ,
307
307
} ;
308
308
309
+ // Based on https://blog.aziz.tn/2025/01/spotify-fix-lagging-issue-on-scrolling.html
310
+ function applyScrollingFix ( ) {
311
+ const scrollableElements = Array . from ( document . querySelectorAll ( "*" ) ) . filter ( ( el ) => {
312
+ if (
313
+ el . id === "context-menu" ||
314
+ el . closest ( "#context-menu" ) ||
315
+ el . getAttribute ( "role" ) === "dialog" ||
316
+ el . classList . contains ( "popup" ) ||
317
+ el . getAttribute ( "aria-haspopup" ) === "true"
318
+ )
319
+ return false ;
320
+
321
+ const style = window . getComputedStyle ( el ) ;
322
+ return style . overflow === "auto" || style . overflow === "scroll" || style . overflowY === "auto" || style . overflowY === "scroll" ;
323
+ } ) ;
324
+
325
+ for ( const el of scrollableElements ) {
326
+ if ( ! el . hasAttribute ( "data-scroll-optimized" ) ) {
327
+ el . style . willChange = "transform" ;
328
+ el . style . transform = "translate3d(0, 0, 0)" ;
329
+ el . setAttribute ( "data-scroll-optimized" , "true" ) ;
330
+ }
331
+ }
332
+ }
333
+
334
+ const observer = new MutationObserver ( applyScrollingFix ) ;
335
+
336
+ observer . observe ( document . body , {
337
+ childList : true ,
338
+ subtree : true ,
339
+ attributes : false ,
340
+ } ) ;
341
+
342
+ const originalPushState = history . pushState ;
343
+ history . pushState = function ( ...args ) {
344
+ originalPushState . apply ( this , args ) ;
345
+ setTimeout ( applyScrollingFix , 100 ) ;
346
+ } ;
347
+
348
+ window . addEventListener ( "popstate" , ( ) => {
349
+ setTimeout ( applyScrollingFix , 100 ) ;
350
+ } ) ;
351
+
352
+ applyScrollingFix ( ) ;
353
+
309
354
( function waitForPlatform ( ) {
310
355
if ( ! Spicetify . _platform ) {
311
356
setTimeout ( waitForPlatform , 50 ) ;
0 commit comments