Added JSON_UNESCAPED_UNICODE flag to json_encode#176
Open
nalognl wants to merge 1 commit intormariuzzo:masterfrom
Open
Added JSON_UNESCAPED_UNICODE flag to json_encode#176nalognl wants to merge 1 commit intormariuzzo:masterfrom
nalognl wants to merge 1 commit intormariuzzo:masterfrom
Conversation
It helps to dramatically reduce the generated JavaScript file size In my testing, I was able to reduce file size from 170kb to 90kb because I had lots of escaped Cyrillic characters.
|
It's a tiny change, can we just accept it? |
rmariuzzo
approved these changes
Jun 19, 2023
|
What happens if someone's environment is not set to accept files encoded in non-ascii? |
It can be as a configuration option |
|
It would look like this in the config file: <?php
return [
/*
* Determines whether to use the JSON_UNESCAPED_UNICODE flag when encoding
* translation files to JSON.
*
* Setting this to true will prevent Unicode characters from being escaped
* (e.g., "你好" instead of "\u4f60\u597d"), which can reduce file size
* and improve readability.
*
* Set to false to escape Unicode characters for compatibility.
*/
'unescape_unicode' => false,
/*
* Set the names of files you want to add to generated javascript.
* Otherwise all the files will be included.
*
* 'messages' => [
* 'validation',
* 'forum/thread',
* ],
*/
'messages' => [
],
/*
* The default path to use for the generated javascript.
*/
'path' => public_path('messages.js'),
]; |
|
I can make a PR after I get some feedback. This current PR is also mine from the previous company's account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It helps to dramatically reduce the generated JavaScript file size
In my testing, I was able to reduce file size from 170kb to 90kb because I had lots of escaped Cyrillic characters.