-
-
Notifications
You must be signed in to change notification settings - Fork 609
Best practice for creating plugins #4473
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
Comments
It depends on what you want to do with your plugin. Will the plugin do stuff itself or can it use Browsertime to run things and then collect the result? There's message queue that's the central point. Your plugging will get a message when it all starts and the plugin can communicate with other plugins by sending messages in the queue. I would start with just a super simple plugin to verify that it works for you and follow the plugin documentation. Ping me on Slack if you need help.
I think many small plugins is better in the way that you can more easily change which plugins/data you need. Since all data/metrics is passed though the message queue have X plugins that do your job, and then a final plugin that collects all the data from the plugins and then do what you want with the data (store it, parse it or what you want to do).
As long as they do not collide with the sitespeed.io plugin names, it will all work I think.
I would write one plugin that collects the data that you need and then save it in whatever format you need. For example, when Browsertime runs and collects it data, it sends the data/metrics as a JSON in the message queue. You can then have a plugin that acts on that data and pick and choose what you. You can also before the test starts, pass on JavaScript (through the message queue) to Browsertime, so when it runs, it will collect the data you need as extra metrics, and then pass it on in the JSON.
I'm not up to speed with exactly what data that you collect. For example Browsertime use the browser you choose to collect metrics. If you use the Axe plugin, that JavaScript runs after Browsertime collect all metrics (in the same browser session) because the Axe plugin will scroll and potentially move things around on the page. The Lighthouse plugin starts there own Chrome version and run the tests after Browsertime has finished. This is because Lighthouse also do stuff with the page (at least before) that made it harder to move on). Also Lighthouse is tied to specific Chrome versions so it's easier to just let it use what it wants. Just ask if there's something that is unclear or something that should be fixed. If you make your first plugin, I can give feedback. I could need some more documentation to make it easier to make plugins :) |
Question from Slack, there's a user that want to create their own plugin. I'll answer this soon.
The text was updated successfully, but these errors were encountered: