fballiano / openmage-load-javascripts-on-intent

Load javascripts only when the user interacts with your OpenMage website
1 stars 1 forks source link

issue with script loading and configurabile products swatches #2

Open empiricompany opened 5 months ago

empiricompany commented 5 months ago

Configurable product PDP is broken.

If I reload the page with scroll, I have no errors, and the swatches do not have attached events.

If I reload the page with a scroll > 0, I get this error in the console:

Uncaught ReferenceError: spConfig is not defined
    <anonymous> https://openmage-latest.loc/default/test-configurable.html line 916 > eval:3
    createResponderForCustomEvent https://openmage-latest.loc/js/prototype/prototype.js:7289
    fireEvent_DOM https://openmage-latest.loc/js/prototype/prototype.js:7148
    fire https://openmage-latest.loc/js/prototype/prototype.js:7137
    _methodized https://openmage-latest.loc/js/prototype/prototype.js:456
    fireContentLoadedEvent https://openmage-latest.loc/js/prototype/prototype.js:7324
    createResponder https://openmage-latest.loc/js/prototype/prototype.js:7273
    onload https://openmage-latest.loc/default/test-configurable.html:918
    FbLoadScripts https://openmage-latest.loc/default/test-configurable.html:913
    FbLoadScripts https://openmage-latest.loc/default/test-configurable.html:905
    EventListener.handleEvent* https://openmage-latest.loc/default/test-configurable.html:928
    <anonymous> https://openmage-latest.loc/default/test-configurable.html:928
[test-configurable.html line 916 > eval:3:67](https://openmage-latest.loc/default/test-configurable.html%20line%20916%20%3E%20eval)

Probably, scripts are not executed in the correct order or some events, like DOMContentLoaded, are not fired correctly.

I have encountered a similar problem in this proof of concept extension here:

https://github.com/empiricompany/openmage_pagespeed/blob/master/app/code/community/Pagespeed/Js/Model/Observer.php