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

Generate unique enqueue handle based on URL #1

Closed
swashata opened this issue Oct 21, 2018 · 0 comments
Closed

Generate unique enqueue handle based on URL #1

swashata opened this issue Oct 21, 2018 · 0 comments
Assignees

Comments

@swashata
Copy link
Owner

Right now, it is very much possible that a same file remains is under different entry-points for a particular app. Webpack chunk splitting works this way and creates shared chunks to prevent duplicate.

When this is the case, if we were to enqueue two different entry-points with same chunk, it will be enqueued twice.

One way to prevent it is by defining $handle programmatically (thereby remove user access).

It should be based on following:

  1. $appName.
  2. $dir ($source).
  3. $js URL (relative URL like app/main.js, app/common.js).

We can combine three and create a string which should be same regardless of entry-point. wp_enqueue_script and wp_enqueue_style will handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant