php - What are the benefits of using AppAsset to manage static resources in Yii?
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 13:01:16
0
3
445

When I am learning Yii recently and loading CSS, JS, etc., I can load resources by directly writing link tags or using AppAsset. So the question is, which method is better and why?

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
巴扎黑

Yii’s AppAsset can realize automatic loading of static file dependencies and compression and merging of multiple files.
For example, if you have a plug-in that relies on jQuery, after using AppAsset, the system will automatically load the plug-in after jQuery, and can merge multiple js files into one and compress them, reducing the number of times the page loads files.

迷茫

Personally, I think it’s for the purpose of protecting the directory structure

黄舟

There are many benefits. It can cache files. The cache directory is the cache directory of your project. If you don’t want people to know the addresses of your files, it will be very safe to use AppAsset because others cannot go there based on the address of your files. Do some tricks on your website.

Also, the styles in the extension will also be cached. If you directly use an address like vendor/kuozhan/web/css/style.css, then you will expose something, which is very dangerous. On the contrary, if you use appasset, it will only display /assets/ead333c7/yii.js, which is very spiritual. If your opponent can't guess your thoughts, you win.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template