MozaikAgency / wp-theme-starter

WordPress theme starter-kit, build tools included :smile:
MIT License
392 stars 70 forks source link

Question on plugins using Javascript #252

Closed marcc1213 closed 8 years ago

marcc1213 commented 8 years ago

Great work, thanks for making this public. I had a question regarding plugins and webpack. What happens when a site administrator later installs some WordPress plugin that has some JavaScript code packaged with it? Do they have to account for that in the gulpfile? This had caused issues when we tried something similar with RequireJS. While that was great for our production effort, we couldn't expect clients to add shims as needed to the RequireJS config and the third-party non-AMD compliant JS in the plugins threw all sorts of errors.

Maximilianos commented 8 years ago

Yeah, we use the theme-starter to build bespoke themes for our clients that are usually maintained by us or another capable team. As such adding functionality would usually not be only up to the client, it would usually go through us or someone else who understands what impacts performance and how they can provide the solution while working with the theme's "framework". That's how we tend to avoid this problem.

The first step to making it simpler/safer for clients to be able to add plugins to their site would be to use the external lib pattern when including core libs (like jQuery) to enable their use by plugin javascript. We often use this to support Contact Form 7 javascript for example.

In terms of shimming non-module (AMD/CommonJS/ES6) stuff, webpack is more friendly in that regard, so I don't think we've run into too many problems with this.

TL;DR; In general, it can bad for performance if the client starts adding plugins and does not intelligently integrate them with the theme's build process. Nevertheless, it should still work. So using the theme is not a blocker for clients adding plugins with JS/CSS it just might not be great for perf.

marcc1213 commented 8 years ago

That makes sense. Thank you for the reply. We often maintain sites as well - but often a client will have an external agency managing inbound marketing and they go crazy with the plugins. We just had an issue where this agency installed three different plugins to embed Twitter feeds (that we already had working in place in the template files)

Maximilianos commented 8 years ago

Technically there is no real way to stop a situation like the one you described from happening; particularly if the people involved are determined :) Its a classic pebkac issue. But, of course, it is also a communication issue. There needs to be clear communication between you and the client of how the project can and should not be modified after handoff and crucially why this is the case. After that, its on them to follow the rules or ask for help.

novweb commented 7 years ago

Can you help me with config Contact Form 7 to work with theme-starter? For now it seams that CF7 scripts not even running. Thank you