-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Remove inline scripts from the build #27004
Comments
Do you mean disabling JS entirely, or just |
I would like to move the inline scripts to external files because if used in some environments (Browser Extensions) it causes security problems |
@danielroe you have some ideas in mind? |
This should be possible as is, with a module or configuration in your project. |
but how should I do it? @danielroe |
@danielroe I encountered the same problem, I want to use Nuxt applications to output to smart TV Samsung via webview and due to the security policy I cannot use inline scripts with content. And Nuxt generates configuration scripts inside the body. How do I move this script content into separate file? <script>window.__NUXT__={};window.__NUXT__.config={public:{...},app:{baseURL:"/",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script> |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
I am also looking for this feature, is there anyway we can get this script removed as an inline script? It prevents me from being able to effectively create a good CSP policy and im forced to use |
So, how can we remove that? |
I wrote a powershell script that removes the tags and moves them to an external file and then adds the generated file to the generated HTML files. @snoweuph |
@CodeCube0 will you share?) |
powershell would need mean we would need to get some way to get a dos system in our jenkins for deployment (and we devs also dont have a dos system) |
For Windows with powershell:
For MacOS or Linux with bash:
|
@CodeCube0 hello, I too have the same problem. How can I apply this to my nuxt3 build? (i'm using ubuntu) How can I apply it in the .ouput folder? |
Would also like to have this as a standard feature. |
It would be great to see this as a third-party module to start with.
|
This could be more complex than we think. If we are willing to accept using this feature only in the scenario where |
yes, in fact I use the script above with ssr set to false |
https://www.npmjs.com/package/nuxt-inline-scripts maybe you can use this package |
Describe the feature
Hi Development Team,
I hope everything is going well. I would like to propose a new feature for Nuxt.js that could be very useful for many developers: the ability to remove inline scripts from the build.
Currently, when building a Nuxt.js project, JavaScript scripts can be embedded directly into the HTML pages. However, this practice can increase the page size and negatively impact performance, especially on devices with slow or limited internet connections.
My proposal is to implement an option in the Nuxt.js configuration that allows developers to specify whether they want to include inline scripts or prefer to exclude them from the final build. This would allow developers to optimize their applications for performance by reducing the overall page size and improving the user experience.
This feature could be implemented through a setting in the Nuxt.js configuration file, for example:
With this setting, developers could easily control whether they want to include inline scripts in the build or not.
I understand that this change may require some significant adjustments within the core of Nuxt.js, but I believe the performance and page load optimization benefits would definitely make it worthwhile.
Would it be possible to consider including this feature in future versions of Nuxt.js? It would be great to have this option available to further enhance web development with Nuxt.js.
Thank you for your attention and for all the work you do to continually improve Nuxt.js.
Best regards.
Additional information
Final checks
The text was updated successfully, but these errors were encountered: