简体   繁体   English

如何gzip或压缩.json文件并在前端.js中使用它

[英]how to gzip or compress a .json file and use it in the frontend .js

i have big json file that i load in the index.js On page load (javascript) file which leads to increase in the time of loading the page. 我在index.js页面加载(javascript)文件中加载了一个很大的json文件,这导致加载页面的时间增加了。

What should i use to reduce this so that the page loads fast? 我应该使用什么来减少这种情况,以便快速加载页面?

You need to enable gzip on your server level, In configuration compressableMimeType you can specify which type of data to be compressed. 您需要在服务器级别启用gzip,在配置compressableMimeType中,您可以指定要压缩的数据类型。

  <Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444"
compression="on" compressableMimeType="text/html,
text/xml,text/plain,text/javascript,text/css,application/json" />

You can visit http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/ for configuration steps 您可以访问http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/了解配置步骤

In your Apache configuration, set mod_deflate parameters. 在您的Apache配置中,设置mod_deflate参数。 See here for complete doc 查看完整的文档

Depending on your configuration, apache config could be located: 根据您的配置,可以找到apache config:

Windows C:\\Program Files\\Apache Group\\Apache2\\conf\\httpd.conf Linux: /etc/httpd/conf/httpd.conf Windows C:\\ Program Files \\ Apache Group \\ Apache2 \\ conf \\ httpd.conf Linux:/etc/httpd/conf/httpd.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 压缩gzip文件问题 - compress gzip file issue 如何使用.htaccess中的gzip压缩“ .js?ver = XXX” - How to compress “.js?ver=X.X.X” with gzip in .htaccess 如何在前端js文件中安装、导入和使用DOMPurify? - How to install, import and use DOMPurify in frontend js file? Vue js我需要将文件压缩为gzip并将其发送到后端 - Vue js i need to compress file to gzip and send it to the back-end 如何使用 gzip 压缩压缩 angular 4 应用程序中的 JSON 数据并使用 Http post 将其发送到服务器? - How to Compress JSON data in angular 4 app using gzip compression & send it to server using Http post? 如何在Shopify中使用gzip压缩资源? - How can I compress resource with gzip in Shopify? 如何在node.js-Backend和前端中的单独js文件中使用函数? - How can I use a function in a separate js file in my node.js-Backend as well as in my frontend? 浏览器Javascript:将Json压缩为gzip,然后上传到S3预签名URL - Browser Javascript: Compress Json to gzip and upload to S3 presigned URL 如何在前端js中使用symfony控制器变量? - how to use symfony controller variables in frontend js? 如何将json文件中的内容发送到前端? - How to send the content in the json file to the frontend?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM