Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Mission Control's JavaScript need to be preloaded? [importmaps] #132

Open
searls opened this issue Jun 18, 2024 · 1 comment
Open

Comments

@searls
Copy link

searls commented Jun 18, 2024

Currently, I'm seeing this warning in my browser console everywhere in my app, even though mission control is only available on one authenticated route:

The resource /assets/mission_control/jobs/application-8d538c5b.js was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it wasn't preloaded for nothing.

This is because the gem's importmap.rb has every dependency set to preload: true, as in:

pin "application-mcj", to: "mission_control/jobs/application.js", preload: true

And (I think?) because the engine appends all these paths to the application's importmap config:

      initializer "mission_control-jobs.importmap", before: "importmap" do |app|
        app.config.importmap.paths << root.join("config/importmap.rb")
        app.config.importmap.cache_sweepers << root.join("app/javascript")
      end

Having every user, whether or not they are authorized to see the mission control jobs preload all of its JavaScript seems less than optimal. Is there any way around this?

@searls
Copy link
Author

searls commented Jun 18, 2024

One workaround for end users is to mask the pin name and explicitly set preload to false in their own importmap.rb. It seems to work in that it clears the warning but doesn't break the functionality of /jobs

pin "application-mcj", to: "mission_control/jobs/application.js", preload: false

@searls searls changed the title Does Mission Control's JavaScript need to be preloaded? Does Mission Control's JavaScript need to be preloaded? [importmaps] Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant