brusselopole / Worldopole

Worldopole is a third party extension for RocketMap showing some nice statistics.
MIT License
85 stars 78 forks source link

Replace all .js.php files with pure js + ajax json load #258

Open Obihoernchen opened 7 years ago

Obihoernchen commented 7 years ago

Files like js.php etc. maybe some json as well?

SiteEffect commented 7 years ago

What is the value in general, having files named with multiple extensions? For me most of the js.php are more like php.js comparing the code size of each language.

Obihoernchen commented 7 years ago

Yeah but your webserver wouldn't execute php.js as php ;) Its basically a PHP file building a js file. Actually I think it would be a good idea to change the locales loader to return json output so we can just use .js files and Ajax load the returned json and use it inside the js code.

We could cache the generated translation json for a few hours for each user. This would lower server load (locales loader isn't executed with every request anymore) and we wouldn't have these strange .js.php files anymore. And we could switch to on the fly client-side translations easier in the future.

@PoUpA is this actually a valid idea?

friscoMad commented 7 years ago

Yup this can be done, but not sure if it will be enough to remove all php.js as I think some use variables also. locale.loader could be a mix returning the locale as json if called or definining the variables if imported. Caching is just a matter of setting the correct headers.

Obihoernchen commented 7 years ago

aru.php can output locale and pokemon json now 👍 I'm replacing all *.js.php files with *.js files + caching + ajax locale load.