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

Duplicate <link rel='preload'> and <script>, Browser warning to add "crossoriging" to link and "as" to script for Nuxt generated page sources #453

Closed
Envoy49 opened this issue Aug 2, 2022 · 17 comments · Fixed by #476
Assignees
Labels
bug Something isn't working

Comments

@Envoy49
Copy link

Envoy49 commented Aug 2, 2022

Discussed in nuxt/nuxt#10612

Originally posted by Envoy49 August 1, 2022
Hi, I have got two types of browser warnings asking me to add "crossorigin" and "as" to the relevant preloaded JS resources created by NUXT itself.
I have done all research I could, tried different webpack configurations and failed all the time.
I don't understand what is the problem and what is the source of it? Is it because of nuxt-bridge I am using?
Seen similar problems but people had access to the html tag to be able to add missing property, in my case I don't understand how I can manipulate it.

Using : "nuxt-edge": "^2.16.0-27358576.777a4b7f" and "@nuxt/bridge": "npm:@nuxt/bridge-edge", node version: 14.8

Screen Shot 2022-08-01 at 11 53 19 am
Screen Shot 2022-08-01 at 11 53 08 am

I think that I should be able to fix it in nuxt.config but not sure what needs to be done. Will appreciate any help

UPDATE:
I am getting script tags with "as" in the page source. Wondering why the warning still appearing in the console


    <link rel="preload" href="/_nuxt/app~._.nuxt_A.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._.nuxt_A.css" as="style" />
    <link rel="preload" href="/_nuxt/app~._a.css" as="style" />
    <link rel="preload" href="/_nuxt/app~._a.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._l.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._layouts_d.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._n.js" as="script" />
    <link
      rel="preload"
      href="/_nuxt/app~._node_modules_atlas_node_modules_vue_dist_vue.runtime.esm.js~8cb01656.js"
      as="script"
    />
    <link
      rel="preload"
      href="/_nuxt/app~._node_modules_atlas_src_c.js"
      as="script"
    />
    <link rel="preload" href="/_nuxt/app~._node_modules_ba.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_c.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_h.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_i.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_vue-c.js" as="script" />
    <link
      rel="preload"
      href="/_nuxt/app~._node_modules_vue_dist_vue.runtime.esm.js~6acccc03.js"
      as="script"
    />
    <link
      rel="preload"
      href="/_nuxt/header-bar-mobile-menu~._node_modules_atlas_src_components_HeaderBar_HeaderBarMobileMenu.vue~0.js"
      as="script"
    />
    <link rel="preload" href="/_nuxt/pages/index~._c.css" as="style" />
    <link rel="preload" href="/_nuxt/pages/index~._c.js" as="script" />
    <link
      rel="preload"
      href="/_nuxt/pages/_~pages/index~pages/preview/_~pages/search~._c.js"
      as="script"
    />
    <link rel="preload" href="/_nuxt/0.js" as="script" />

I can see this PR ----> nuxt/nuxt#7709 merged back in 2020, related to missing "crossorigin"
Wondering if it fixed issue and I am not using the version which has it missing.

UPDATE:

I just discovered that the same scripts are at the bottom of my page and has "crossorigin" attribute.
So basically first error is coming from the HEAD html tag where I got all my preloaded scripts without "crossorigin" tag and the second error message is coming from bottom of the page where I have "crossorigin" tag withouth "as".


    <script src="/_nuxt/app~._.nuxt_A.js" defer crossorigin></script>
    <script src="/_nuxt/app~._a.js" defer crossorigin></script>
    <script src="/_nuxt/app~._la.js" defer crossorigin></script>
    <script src="/_nuxt/app~._m.js" defer crossorigin></script>
    <script src="/_nuxt/app~._n.js" defer crossorigin></script>
    <script src="/_nuxt/app~._node_modules_an.js" defer crossorigin></script>
    <script
      src="/_nuxt/app~._node_modules_atlas_src_c.js"
      defer
      crossorigin
    ></script>
    <script src="/_nuxt/app~._node_modules_ba.js" defer crossorigin></script>
    <script src="/_nuxt/app~._node_modules_c.js" defer crossorigin></script>
    <script src="/_nuxt/app~._node_modules_h.js" defer crossorigin></script>
    <script src="/_nuxt/app~._node_modules_i.js" defer crossorigin></script>
    <script src="/_nuxt/app~._node_modules_vue-c.js" defer crossorigin></script>
    <script
      src="/_nuxt/app~._node_modules_vue_dist_vue.runtime.esm.js~6acccc03.js"
      defer
      crossorigin
    ></script>
@Envoy49
Copy link
Author

Envoy49 commented Aug 2, 2022

Updating nuxt-edge and nuxt-bridge to the latest versions didn't help to solve the problem.

"@nuxt/bridge-edge": "^3.0.0-27657000.c87fdbe",
"nuxt-edge": "^2.16.0-27616340.013f051b",

@Envoy49
Copy link
Author

Envoy49 commented Aug 2, 2022

tried

  router: {
    prefetchLinks: false
  }

and

  render: {
    resourceHints: false
  }
  

and

 optimization: {
      sideEffects: false,
  }

and

export default {
  head: {
    script: [
      {
        src:
          'https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver',
        body: true
      }
    ]
  }
} 

didn't work

Tried preload-webpack-plugin, couldn't make it work

Couldn't also make this parameter work:

  output: {
    crossOriginLoading: "anonymous",
  },

@danielroe danielroe transferred this issue from nuxt/nuxt Aug 2, 2022
@Envoy49
Copy link
Author

Envoy49 commented Aug 2, 2022

Hi @danielroe ,
Thanks for moving this to the correct repo. I was wondering if you could give me some clue or hint to move in certain direction?

@Envoy49 Envoy49 changed the title Browser warning asking to add "crossoriging" and "as" for Nuxt generated page sources Duplicate <link rel='preload'> and <script>, Browser warning to add "crossoriging" to link and "as" to script for Nuxt generated page sources Aug 2, 2022
@danielroe
Copy link
Member

This will be fixed when we upgrade to the new version of vue-bundle-renderer.

@danielroe danielroe self-assigned this Aug 3, 2022
@danielroe danielroe added the bug Something isn't working label Aug 3, 2022
@duboloms
Copy link

duboloms commented Aug 7, 2022

@danielroe Do you know how long it will take?

@danielroe
Copy link
Member

Should be this week.

@duboloms
Copy link

duboloms commented Aug 7, 2022

@danielroe I hope all will be fine and soon :)

@kissu
Copy link

kissu commented Aug 7, 2022

@duboloms please bit a bit patient. 😺 🤗

@antlionguard
Copy link

@duboloms please bit a bit patient. 😺 🤗

@danielroe I hope all will be fine and soon :)

vue-bundle-renderer will be updated with #461. But this pr has got some error on testing process. They will be merge pr after the errors are fixed.

@Envoy49
Copy link
Author

Envoy49 commented Aug 17, 2022

@danielroe, I was wondering if this is available for upgrade yet or it hasn't been released yet? Which version I should update it to?

@antlionguard
Copy link

Same. I installed latest version but vue-bundle-renderer still 0.3.9

image

@danielroe
Copy link
Member

Yes, the automatic release didn't trigger for some reason.

@Envoy49
Copy link
Author

Envoy49 commented Aug 17, 2022

@danielroe, could you please let us know when the release will be available?

@Envoy49
Copy link
Author

Envoy49 commented Aug 25, 2022

@danielroe Sorry, do we have any news on this one being released? Should we keep this open?

@danielroe
Copy link
Member

Apologies @Envoy49 🙏 This should be released in the latest edge version.

@Envoy49
Copy link
Author

Envoy49 commented Sep 7, 2022

Thanks for your hard work @danielroe , can confirm that it has been fixed.

@DulcePC
Copy link

DulcePC commented Dec 20, 2022

I'm using nuxt3, where I had the same problem, I changed the ssr to true, I know the problem comes from the preload but I really don't know why this fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants