laravel / nova-issues

554 stars 35 forks source link

CloudFlare Rocket Loader bricks JavaScript #3831

Closed faustbrian closed 2 years ago

faustbrian commented 2 years ago

Description:

Setting up a new project with nothing but Laravel Nova installed and running into an issue with loading it once deployed. Locally everything loads but as soon as it is live and behind CloudFlare with Rocket Loader enabled the following error shows up.

app.js?id=d9622fea88363d50b3f9e835744d0058:1 Uncaught TypeError: Cannot read properties of undefined (reading 'use')
    at ir.registerStoreModules (app.js?id=d9622fea88363d50b3f9e835744d0058:1:66943)
    at ir.liftOff (app.js?id=d9622fea88363d50b3f9e835744d0058:1:64196)
    at <anonymous>:2:14
    at t.activateScript (rocket-loader.min.js:1:11855)
    at rocket-loader.min.js:1:11052
    at t.run (rocket-loader.min.js:1:11259)
    at P (rocket-loader.min.js:1:3128)
    at Object.callback (rocket-loader.min.js:1:2851)
    at t.run (rocket-loader.min.js:1:11340)
    at rocket-loader.min.js:1:11156

This error disappears and everything loads as expected as soon as you disable Rocket Loader. This wasn't an issue with Nova 3.0 and was reproduced to work fine when spinning up a new project with it.

crynobone commented 2 years ago

Unfortunately, I don't think we would be able to support integration with Rocket Loader. All JavaScript has already deferred to the very last of the layout.

faustbrian commented 2 years ago

What's the difference compared to Nova 3? Works flawlessly there, same for 1 and 2 so it's obviously not a technical issue with how JavaScript works. Asking users to disable a major performance and stability booster from CloudFlare for the sake of an admin panel is quite a big request because that will massively impact end-user performance on the front-end.

vladles commented 2 years ago

Fetched the same issue. I fixed it as this created the additional rule with disabled the Rocket Loader for deployed domain/subdomain/path

https://support.cloudflare.com/hc/en-us/articles/218411427