Skip to main content

SlimIt - JavaScript minifier

Project description

SlimIt is a JavaScript minifier written in Python. It compiles JavaScript into more compact code so that it downloads and runs faster.

At version 0.1 it provides only a JavaScript lexer.

Using lexer in your project

>>> from slimit.lexer import Lexer
>>> lexer = Lexer()
>>> lexer.input('a = 1;')
>>> for token in lexer:
...     print token
...
LexToken(ID,'a',1,0)
LexToken(EQ,'=',1,2)
LexToken(NUMBER,'1',1,4)
LexToken(SEMI,';',1,5)

You can get one token at a time using token method:

>>> lexer.input('a = 1;')
>>> while True:
...     token = lexer.token()
...     if not token:
...         break
...     print token
...
LexToken(ID,'a',1,0)
LexToken(EQ,'=',1,2)
LexToken(NUMBER,'1',1,4)
LexToken(SEMI,';',1,5)

LexToken instance has different attributes:

>>> lexer.input('a = 1;')
>>> token = lexer.token()
>>> token.type, token.value, token.lineno, token.lexpos
('ID', 'a', 1, 0)

Installation

Using pip:

$ sudo pip install slimit

Using easy_install:

$ sudo easy_install slimit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slimit-0.1.tar.gz (12.3 kB view details)

Uploaded Source

File details

Details for the file slimit-0.1.tar.gz.

File metadata

  • Download URL: slimit-0.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for slimit-0.1.tar.gz
Algorithm Hash digest
SHA256 ace97dc13e6eae559da08df1750b1bb0f26e6ec7971b5d982e77871caf8e088e
MD5 9884aa147a399447c125be27912ccd14
BLAKE2b-256 12d329a9eb758874d800ce2073f9a1ce4b62acaab047ef575ebb5cf03e3ff013

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page