Closed jurijc closed 1 year ago
Interesting idea! The size of the current beta is only 15kb now simply by upgrading the bundler, but you are right, there is much "advanced" functionality here. However, which functionality is "needed" will be different on every website, so I'm not sure this would create more confusion/support requests than help. But I will experiment with this a little and let you know.
(I am also considering making AJAX mode the default in a future major version, so this topic is relevant, yes.)
Hello Benjamin, great that this idea is on time, thanks for feedback
if you look from side of support requests - then by default it's full version and it's for average user, so nothing would change. For someone who understands there will be option in admin to include only small version. Or pick one of 1-3 versions for general use cases (for example "I need to detect user location using get_info()" and so on, because you have already separated code for each functionality in bundler) Have a great evening
I have committed a "minimal" file now that only has get_info() that has 7.4kB, if I also remove the localStorage cache it's 6.1kB. For what it does, this is still a lot - there is a lot of "syntactic sugar" to make it easier to use. If I leave away the Record class, returning simply the json data, it's 4.4kB (3.1kB without localstorage). Which of the 4 versions would you use?
I would try 4.4kb version, I think cache is important it's saves ajax call that is much slower than extra 1.3kb.
Note to self, this is what needs to be done before release:
Size of frontend JS is 20.8kb, which is not small and can affect frontend and page load times. Functionality to detect IP GEO is usually needed onload so it can't be deferred and loaded later.
I would suggest to create separate versions depending on what user needs (can be selected in options) and enqueue that exactly version. That could be two versions: 1) slim, just detection of geo (for example country code, or whole geo_info) 2) full (like it is right now)
Maybe there is better solution, for example to have slim JS snippet to get country code of current ip without even using frontend.js ?
Thank you for your plugin!