Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the WordPress plugin for the combination of CSS and JS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what is the WordPress plug-in for the merger of CSS and JS, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

We usually consider merging multiple CSS or JS into one file output. To solve this problem, I wrote this WordPress plug-in to achieve this purpose in WordPress.

Realization principle

If you have read my previous "PHP merge compressed css output Modular css Writing", you can first understand some of my handling of cache files, as well as some ideas about merging files and compressing code. The implementation principle of this plug-in is basically similar to that described in the above article.

Installation

First, download the plug-in, which I host on my GitHub, which you can download from this page. After downloading, unzip it, and upload the unzipped folder directly to your WordPress plugin directory. Then go backstage to enable it.

Use

Enter the background, under the "Settings" menu, there is a submenu "Minify", after entering, you can set its various options, and there are comments, you can understand the function.

To use wp-minify, you have to modify the theme because you output css and js differently. In your theme, delete the original CSS and JS output and output JS using the following method:

The method of outputting css is the same, except that you use another function, wp_minify_css (). The argument to the function is an array, and the elements inside the array are the path to the script file, which is written to the full relative path at the root of the WordPress installation directory.

Why write a script relative to the root directory of WordPress? Instead of relative to your current theme catalog? In fact, the reason is very simple, because the css or js you quote is not necessarily under the theme directory, sometimes you will refer to the styles or scripts under other directories. Of course, this is a relative path, and you can even reference a script from a directory above WordPress, such as "/.. / test.js", but note that the script must start with /, otherwise it may cause relative path errors.

Of course, the specific method of use can be easily modified or developed by yourself after you understand the principle.

This is the end of the WordPress plug-in on what is the merger of CSS and JS. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report