IP Library Granted Patent US 9,747,385
Granted Patent B2
US 9,747,385 · App. 14/881,066 · Granted Aug 29, 2017

Compression of cascading style sheet files

Inventor: Lixin Hao (Hangzhou, CN)
Assignee: ALIBABA GROUP HOLDING LIMITED
G06F17/30896G06F17/2252H03M7/30
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 9,747,385
App. No.
14/881,066
Granted
Aug 29, 2017
Kind
B2
Abstract

One embodiment of the present invention provides a system for facilitating compression of a Cascading Style Sheet (CSS) file. During operation, the system stores the CSS file in a local storage device and identifies a merge parameter in the CSS file. The merge parameter can be one of: a repeated selector, a repeated property in a selector, and a same value of a property in different selectors. The system then determines whether a merge condition is satisfied for the merge parameter and merges the merge parameter in the CSS file to obtain a compressed merge parameter. The merge condition indicates whether merging of the merge parameter is consistent with original style in the CSS file.

Claims (61)

1. A method for facilitating compression of a Cascading Style Sheet (CSS) file, the method comprising:

identifying, by a server hosting a web page associated with the CSS file, a first selector and a second selector in the CSS file by identifying a repeated code in the first and second selectors, wherein the repeated code appears in each of the first and second selectors;

determining whether the first selector and the second selector are adjacent in the CSS file;

in response to the first and second selectors not being adjacent, determining whether a third selector between the first and second selectors includes a property included in the first and second selectors;

in response to the third selector not including the property,

determining that merging the repeated code in the first and second selectors produces a same style for the web page as the original style in the CSS file;

merging the repeated code in the first and second selectors in the CSS file to obtain a compressed CSS file;

receiving a request for the web page; and

in response to receiving the request for the web page, generating a web response comprising the web page and the compressed CSS file.

2. The method of claim 1 , further comprising determining whether the compressed CSS file is valid based on a length of the merged repeated code.

3. The method of claim 1 , wherein in response to the third selector including the property, the method further comprises determining whether the repeated code includes one or more of:

a same value in the first, second, and third selectors;

different priorities in the first, second, and third selectors.

4. The method of claim 1 , further comprising determining that merging the repeated code in the first and second selectors produces a same style for the web page as the original style in the CSS file further in response to determining that:

a latter value of a property of the repeated code overwrites a former value of the property and the latter value has an equal or higher priority; or

a former value of the property overwrites a latter value of the property and the former value has a higher priority.

5. The method of claim 1 , wherein merging the repeated code comprises removing a second value of a property, wherein the second value appears before a first value, has a lower priority than the first value, or has an overwriting relationship with the first value.

6. The method of claim 1 , further comprising:

representing selectors of the CSS file and corresponding properties in a table; and

determining a common area in the table for a respective property.

7. The method of claim 6 , further comprising:

identifying a current maximum common area in the table for a property;

extracting the property as a common factor;

merging the common factor across a respective selector comprising the property.

8. The method of claim 1 , further comprising generating the compressed CSS file based on a plurality of merged repeated codes.

9. The method of claim 1 , further comprising, prior to generating the compressed CSS file, organizing properties of all selectors in the CSS file in an alphabetic order.

10. A non-transitory storage medium storing instructions, which when executed by a processor cause the processor to perform a method for facilitating compression of a Cascading Style Sheet (CSS) file, the method comprising:

identifying, by a server hosting a web page associated with the CSS file, a first selector and a second selector in the CSS file by identifying a repeated code in the first and second selectors, wherein the repeated code appears in each of the first and second selectors;

determining whether the first selector and the second selector are adjacent in the CSS file;

in response to the first and second selectors not being adjacent, determining whether a third selector between the first and second selectors includes a property included in the first and second selectors;

in response to the third selector not including the property, determining that merging the repeated code in the first and second selectors produces a same style for the web page as the original style in the CSS file; and

merging the repeated code in the first and second selectors in the CSS file to obtain a compressed CSS file;

receiving a request for the web page; and

in response to receiving the request for the web page, generating a web response comprising the web page and the compressed CSS file.

11. The non-transitory storage medium of claim 10 , wherein the method further comprises determining whether the compressed CSS file is valid based on a length of the merged repeated code.

12. The non-transitory storage medium of claim 10 , wherein in response to the third selector including the property, the method further comprises determining whether the repeated code includes one or more of:

a same value in the first, second, and third selectors;

different priorities in the first, second, and third selectors.

13. The non-transitory storage medium of claim 10 , wherein the method further comprises determining that merging the repeated code in the first and second selectors produces a same style for the web page as the original style in the CSS file further in response to determining that:

a latter value of a property of the repeated code overwrites a former value of the property and the latter value has an equal or higher priority; or

a former value of the property overwrites a latter value of the property and the former value has a higher priority.

14. The non-transitory storage medium of claim 10 , wherein merging the repeated code comprises removing a second value of a property, wherein the second value appears before a first value, has a lower priority than the first value, or has an overwriting relationship with the first value.

15. The non-transitory storage medium of claim 10 , wherein the method further comprises:

representing selectors of the CSS file and corresponding properties in a table; and

determining a common area in the table for a respective property.

16. The non-transitory storage medium of claim 15 , wherein the method further comprises:

identifying a current maximum common area in the table for a property;

extracting the property as a common factor;

merging the common factor across a respective selector comprising the property.

17. The non-transitory storage medium of claim 10 , wherein the method further comprises generating the compressed CSS file based on a plurality of merged repeated codes.

18. The non-transitory storage medium of claim 10 , wherein the method further comprises, prior to generating the compressed CSS file, organizing properties of all selectors in the CSS file in an alphabetic order.

19. A computing system for facilitating compression of a Cascading Style Sheet (CSS) file and hosting a web page associated with the CSS file, the computing system comprising:

a processor;

a memory coupled to the processor and storing instructions, which when executed by the processor cause the processor to perform a method, the method comprising:

identifying a first selector and a second selector in the CSS file by identifying a repeated code in the first and second selectors, wherein the repeated code appears in each of the first and second selectors;

determining whether the first selector and the second selector are adjacent in the CSS file;

in response to the first and second selectors not being adjacent, determining whether a third selector between the first and second selectors includes a property included in the first and second selectors;

in response to the third selector not including the property, determining that merging the repeated code in the first and second selectors produces a same style for the web page as the original style in the CSS file;

merging the repeated code in the first and second selectors in the CSS file to obtain a compressed CSS file;

receiving a request for the web page; and

in response to receiving the request for the web page, generating a web response comprising the web page and the compressed CSS file.

Assignments (3)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 11, 2020
From: ADVANTAGEOUS NEW TECHNOLOGIES CO., LTD.
To: ADVANCED NEW TECHNOLOGIES CO., LTD.
Reel/Frame 053745/0667 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 1, 2020
From: ALIBABA GROUP HOLDING LIMITED
To: ADVANTAGEOUS NEW TECHNOLOGIES CO., LTD.
Reel/Frame 053663/0280 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 19, 2015
From: HAO, LIXIN
To: ALIBABA GROUP HOLDING LIMITED
Reel/Frame 036825/0759 →
Priority Claims (1)
CN 2014 1 0545554 · Oct 15, 2014 · national
Continuity (1)
Related Publication 20160110324A1 · Apr 21, 2016