Javascript-cdn How to solve the implementation of JS/CSS automatic compression scheme? (via Jsminify)

Source: Internet
Author: User

Requirements Description

Website www.xxx.com, Environment WIN64 WAMP, distribution 3 Too server, main 1 units, 3 units. The images used in the/css/js are placed in the www.xxx.com/Public/directory. Requirements are introduced in the site/public directory js/css will automatically compress, facilitate the opening speed.

Original plan

Through Jsminify + htaccess, the request address of the JS/CSS in the Access/public directory is directed to PHP in Jsminify and then automatically compressed via the Jsminify package. This way, programmers and designers upload CSS JS without any action. Very convenient.

Changes in requirements

Requires that all resources in the/public be transferred to the CDN server first. CDN Server Configuration LN (Linux + nignx), does not support PHP does not support htaccess. How do you minimize your workload?

Personal Solutions

1)每次上传Public 中的CSS/JS 先试用Notepad++ 中的JSMini插件进行压缩格式化。然后再传不足:网站仍旧大改动中,每次都可能修改很多JS CSS,如果一个个压缩,很可能遗漏或者有些错误。2)自己试用JSMinify 制作一个插件,扫描指定目录中的JS/CSS 文件,然后压缩后存放。不足:仍旧是需要手动操作,且制作这个插件需要花费一定时间。3)寻找网络上的批量压缩工具问题:目前没有找到。

Connection

Google JSMinfiy:https://code.google.com/p/minify/

How can we simplify?

The scenario I'm using now is to create a script locally with PHP that copies all the resources of the public directory (not CSS/JS) to another directory, CSS/JS takes http://localhost/min/index.php?filename=$ FileName is saved by the way it is downloaded. It's a bit simple and rude, but it omits the hassle of creating programs on the Minify class library.

Reply content:

Requirements Description

Website www.xxx.com, Environment WIN64 WAMP, distribution 3 Too server, main 1 units, 3 units. The images used in the/css/js are placed in the www.xxx.com/Public/directory. Requirements are introduced in the site/public directory js/css will automatically compress, facilitate the opening speed.

Original plan

Through Jsminify + htaccess, the request address of the JS/CSS in the Access/public directory is directed to PHP in Jsminify and then automatically compressed via the Jsminify package. This way, programmers and designers upload CSS JS without any action. Very convenient.

Changes in requirements

Requires that all resources in the/public be transferred to the CDN server first. CDN Server Configuration LN (Linux + nignx), does not support PHP does not support htaccess. How do you minimize your workload?

Personal Solutions

1)每次上传Public 中的CSS/JS 先试用Notepad++ 中的JSMini插件进行压缩格式化。然后再传不足:网站仍旧大改动中,每次都可能修改很多JS CSS,如果一个个压缩,很可能遗漏或者有些错误。2)自己试用JSMinify 制作一个插件,扫描指定目录中的JS/CSS 文件,然后压缩后存放。不足:仍旧是需要手动操作,且制作这个插件需要花费一定时间。3)寻找网络上的批量压缩工具问题:目前没有找到。

Connection

Google JSMinfiy:https://code.google.com/p/minify/

How can we simplify?

The scenario I'm using now is to create a script locally with PHP that copies all the resources of the public directory (not CSS/JS) to another directory, CSS/JS takes http://localhost/min/index.php?filename=$ FileName is saved by the way it is downloaded. It's a bit simple and rude, but it omits the hassle of creating programs on the Minify class library.

Why not use grunt or gulp for automated compression

Can a CDN do a mirrored backup? Resources also put on the source station, request to request CDN,CDN above no resources, let CDN to Source station synchronization. Do a good back-sourcing strategy.

I was using the Yeoman scaffold.

With me, lazy, even if you do not have the desire to do self-compression, but also lazy to write the plugin (but I wrote the code compression ...). )

There's no such thing as a CDN that supports self-compression and cache, like Cloudflare. This is the quickest and best solution.

If you cannot change CDN,CDN and do not support a custom environment, local compression is the only solution, so you can consider modifying the copy of the used foot, which is actually self-compressing.

In the meantime, it takes time to write a program, and time to spend on asking for help when you're turning yourself into a program and then you're going to execute the order.

You already know which is the most convenient.

The answer is probably the same as you lazy? If you haven't had a perfect solution for a few days, I'll spend a few minutes helping you write one. It's really easy.

Occupy the pit.

You can try Google's nginx plugin pagespeed!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.