Up until now, third party scripts need to be modified to allow Orejime to handle them correctly.
This implies namespacing regular attributes, labeling them, and ensuring the label matches with the config.
This latter part is often causing problems, as the labels must match but there is no way to enforce this over time.
This leads to desynchronizations when the code changes, and Orejime still working without errors but not actually acting on the scripts.
This is unavoidable with the current architecture but could be mitigated by changing the way scripts are loaded.
Options
Other CMP tend to provide an extensive list of predefined third-party services (think Google Analytics, Matomo, ...) that can inject scripts with little configuration (i.e. a site id).
This avoids any desynchronizations, as the CMP is entirely responsible of injecting the scripts.
However, it is on the CMP to provide scripts for just about any service, in any given version, which is almost impossible.
A middle ground could consist in moving scripts to the Orejime config, but in the user-land.
Instead of setting up regular script tags in the HTML, the user would put their content in the config, in each app declaration.
This would let Orejime own their lifecycle without actually providing a predefined list of services.
const config = {
apps: [
{
name: 'gtm',
title: 'Google Tag Manager',
cookies: [],
// the exact code that we would find in the original script tag
script: () => {
(function(w, d, s, l, i) { /* GTM code */ })(window,document, 'script', 'dataLayer', 'GTM-YOLO');
},
// an optional list of HTML attributes for the injected script tag
scriptAttributes: {
crossorigin: true
}
}
]
};
This would be a breaking change, requiring a rewrite of any user config. Maybe this could be an alternative mode that could coexist with the current one, making it easier to switch. The current one could then be deprecated and removed in the future.
Context
Up until now, third party scripts need to be modified to allow Orejime to handle them correctly. This implies namespacing regular attributes, labeling them, and ensuring the label matches with the config. This latter part is often causing problems, as the labels must match but there is no way to enforce this over time. This leads to desynchronizations when the code changes, and Orejime still working without errors but not actually acting on the scripts. This is unavoidable with the current architecture but could be mitigated by changing the way scripts are loaded.
Options
Other CMP tend to provide an extensive list of predefined third-party services (think Google Analytics, Matomo, ...) that can inject scripts with little configuration (i.e. a site id). This avoids any desynchronizations, as the CMP is entirely responsible of injecting the scripts. However, it is on the CMP to provide scripts for just about any service, in any given version, which is almost impossible.
A middle ground could consist in moving scripts to the Orejime config, but in the user-land. Instead of setting up regular script tags in the HTML, the user would put their content in the config, in each app declaration. This would let Orejime own their lifecycle without actually providing a predefined list of services.
Example
Before
After
Potential issues