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
Clean up JSON2 in piwik.js #6093
Comments
we use JSON2 see https://github.com/piwik/piwik/blob/master/js/piwik.js#L1453 |
what is JSON2? any link to standard? |
@NekR |
We could actually indeed use builtin JSON API in case it exists. JSON2 is a lib that we use as JSON API it is not supported by all browser see http://caniuse.com/#search=json |
I knew what json2 is a pollyfill, but almost all browsers have builtin version. So it's better to have (function () {
'use strict';
if (window.JSON) {
window.JSON2 = window.JSON;
return;
} else {
window.JSON2 = {};
}
// ... This is fast example how it should be. Or you can just replace everywhere word 'JSON2' to 'JSON'. |
makes sense. We could even think about removing JSON2 at some point completely. I just had a look and the browsers that do not support JSON builtin are less than 0.5% (IE7 has about 0.2%) and JSON is only needed when custom variables in scope visit are used anyway. |
@halfdan you reopened the issue, what do you think should be the scope? maybe |
@halfdan could you rename ticket to clarify scope? then feel free to assign to Short term if it's a quick fix |
How about using JSON 3 instead?
Also, this will probably fix #5960. |
Looking good to me. The minified version with 8kb is a bit a lot but should be still ok. Could go with this one for like a year and then support only builtin JSON. Alternatively now or like in one year we would simply ignore browsers that do not support builtin JSON. If someone still wants those browsers tracked we could let it up to the user to load a separate file before that provides JSON2 or JSON3. So we would check if there is JSON, if not JSON2, then JSON3. If none is there we do not track on this very outdated browsers. |
Increasing priority as we probably soon could remove JSON2 from piwik.js |
It's currently pretty much only there for IE7 & IE6 see http://caniuse.com/#search=json |
Ok so we won't remove this for a while since we need to support IE7 and IE6. Leaving opened, but decreasing priority |
Any updates on this? I guess you are doing this due to contract duties but still encouraging the user to use IE6 sounds extremely insecure. |
we don't encourage users to use IE6, but we need to track users on IE6 and IE7 and cannot drop those users from tracking yet (we may in the future, though) |
Would it be possible to drop the support for IE<7 in Matomo 4 and remove the JSON fallback from the piwik.js? Now that plugins can modify the piwik.js it may be possible to write a plugin that adds JSON3 for those who still need it (and reducing the load time for everyone else) |
👍 that is doable I'd say. A plugin that adds support for it may be doable as well. Just a side note: JSON3 is currently also used for compatibility with some JS frameworks like older versions of |
@NekR: The reason piwik.js called it JSON2 (even though it was using json.js) was because some browsers provided broken window.JSON implementations. That said, I'm all for dropping the polyfill for Matomo4. |
fixed with #15413, will be included in Matomo 4 |
Here:
https://github.com/piwik/piwik/blob/master/js/piwik.js#L45
You check for JSON2 object in window object which never exists and you always use JS version of JSON instead of builtin.
Also, here #6066 (comment) man said that you do not use json2.js, but you actually do, or at least json.js which is worse.
Refer to this commend for more details: #6066 (comment)
The text was updated successfully, but these errors were encountered: