How to use the jsmin.JavascriptMinify function in jsmin

To help you get started, we’ve selected a few jsmin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javafxports / openjdk-jfx / modules / javafx.web / src / main / native / Source / JavaScriptCore / Scripts / make-js-file-arrays.py View on Github external
parser.print_usage()
        exit(-1)

    namespace = options.namespace
    headerPath = arguments[0]
    sourcePath = arguments[1]
    inputPaths = arguments[2:]

    headerFile = open(headerPath, 'w')
    print('namespace {0:s} {{'.format(namespace), file=headerFile)

    sourceFile = open(sourcePath, 'w')
    print('#include "{0:s}"'.format(os.path.basename(headerPath)), file=sourceFile)
    print('namespace {0:s} {{'.format(namespace), file=sourceFile)

    jsm = JavascriptMinify()

    for inputFileName in inputPaths:
        inputStream = io.FileIO(inputFileName)
        outputStream = StringIO()

        if not options.no_minify:
            jsm.minify(inputStream, outputStream)
            characters = outputStream.getvalue()
        else:
            characters = inputStream.read()

        size = len(characters)
        variableName = os.path.splitext(os.path.basename(inputFileName))[0]

        print('extern const char {0:s}JavaScript[{1:d}];'.format(variableName, size), file=headerFile)
        print('const char {0:s}JavaScript[{1:d}] = {{'.format(variableName, size), file=sourceFile)
github trentrichardson / Clientside / Clientside.py View on Github external
def get_js_minified(self, codestr):
		ins = StringIO(codestr)
		outs = StringIO()				
		JavascriptMinify().minify(ins, outs)	
		min_js = outs.getvalue()				
		if len(min_js) > 0 and min_js[0] == '\n':
			min_js = min_js[1:]				
		return re.sub(r'(\n|\r)+','', min_js)
github trentrichardson / Gedit-Minifier-Plugin / minifier / __init__.py View on Github external
def get_minified_js_str(self, js):
		ins = StringIO(js)
		outs = StringIO()
		
		JavascriptMinify().minify(ins, outs)
		
		str = outs.getvalue()
		
		if len(str) > 0 and str[0] == '\n':
			str = str[1:]
		
		str = re.sub(r'(\n|\r)+','', str)
		
		return str
github analytehealth / django-analytics / setuptools_utils / __init__.py View on Github external
def run(self):
        try:
            import jsmin
        except:
            pass
        djanalytics_js_in = open('djanalytics/templates/djanalytics.js')
        djanalytics_js_out = open('djanalytics/templates/djanalytics.js.min', 'w')
        try:
            jsmin.JavascriptMinify(djanalytics_js_in, djanalytics_js_out).minify()
        finally:
            djanalytics_js_in.close()
            djanalytics_js_out.close()
github jam-py / jam-py / jam / third_party / jsmin / __main__.py View on Github external
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import sys, os, glob
from jsmin import JavascriptMinify

for f in sys.argv[1:]:
    with open(f, 'r') as js:
        minifier = JavascriptMinify(js, sys.stdout)
        minifier.minify()
    sys.stdout.write('\n')
github trentrichardson / Gedit-Clientside-Plugin / clientside / __init__.py View on Github external
def get_minified_js_str(self, js):
		
		ins = StringIO(js)
		outs = StringIO()
		
		JavascriptMinify().minify(ins, outs)
		
		min_js = outs.getvalue()
		
		if len(min_js) > 0 and min_js[0] == '\n':
			min_js = min_js[1:]
		
		min_js = re.sub(r'(\n|\r)+','', min_js)
		
		return min_js
github servo / mozjs / mozjs / python / mozbuild / mozpack / files.py View on Github external
def open(self):
        output = BytesIO()
        minify = JavascriptMinify(self._file.open(), output, quote_chars="'\"`")
        minify.minify()
        output.seek(0)

        if not self._verify_command:
            return output

        input_source = self._file.open().read()
        output_source = output.getvalue()

        with NamedTemporaryFile() as fh1, NamedTemporaryFile() as fh2:
            fh1.write(input_source)
            fh2.write(output_source)
            fh1.flush()
            fh2.flush()

            try:
github 1ec5 / avim / build.py View on Github external
def minify_js(file_path, src):
    """Returns a minified version of the given JavaScript source string."""
    in_str = StringIO(src)
    out_str = StringIO()
    JavascriptMinify().minify(in_str, out_str)
    src = out_str.getvalue()
    in_str.close()
    out_str.close()
    return src
github miracle2k / django-assets / django_assets / filter / jsmin / __init__.py View on Github external
def output(self, _in, out, **kw):
        JavascriptMinify().minify(_in, out)

jsmin

JavaScript minifier.

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages