Skip to content

external script support #774

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

Closed
apekarawang opened this issue Aug 27, 2018 · 1 comment
Closed

external script support #774

apekarawang opened this issue Aug 27, 2018 · 1 comment

Comments

@apekarawang
Copy link

Feature request

What problem does this feature solve?

easy integration of google adsense, recaptcha, etc.

What does the proposed API look like?

// global scripts
// currently only available on `head`
{
scripts: [
    {
      src: 'https://www.google.com/recaptcha/api.js?render=...',
      defer: true,
      async: true,
      pos: 'before'
    }
  ]
},
// per page scripts
nav: [
  {
    text: "Home",
    link: "/", 
    scripts: [
      {
        src: 'https://www.google.com/recaptcha/api.js?render=...',
        defer: true,
        async: true,
        pos: 'before'
      }
    ]
  },
]

How should this be implemented in your opinion?

Are you willing to work on this yourself?**

yes

@ulivz
Copy link
Member

ulivz commented Aug 29, 2018

Thanks for your interest in VuePress, but:

  1. For global scripts, we can use enhanceApp.js and some script loading lib (e.g loadjs) to implement it at userland. you can even inject it at the dev or prod template when we support Config the dev and build html template. #733

  2. For per page scripts, the API you recommended is such complicated, why coupling it with nav config? The simplest way should be monitoring $route changes, and then loading the scripts that you want.

@ulivz ulivz closed this as completed Aug 29, 2018
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

2 participants