MCPcopy Index your code
hub / github.com/totaljs/framework / compressJS

Function compressJS

internal.js:2590–2619  ·  view source on GitHub ↗

* Inline JS compressor * @private * @param {String} html HTML. * @param {Number} index Last index. * @return {String}

(html, index, filename, nomarkup)

Source from the content-addressed store, hash-verified

2588 * @return {String}
2589 */
2590function compressJS(html, index, filename, nomarkup) {
2591
2592 if (!CONF.allow_compile_script)
2593 return html;
2594
2595 var strFrom = '<script type="text/javascript">';
2596 var strTo = '</script>';
2597
2598 var indexBeg = html.indexOf(strFrom, index || 0);
2599 if (indexBeg === -1) {
2600 strFrom = '<script>';
2601 indexBeg = html.indexOf(strFrom, index || 0);
2602 if (indexBeg === -1)
2603 return html;
2604 }
2605
2606 var indexEnd = html.indexOf(strTo, indexBeg + strFrom.length);
2607 if (indexEnd === -1)
2608 return html;
2609
2610 var js = html.substring(indexBeg, indexEnd + strTo.length).trim();
2611 var beg = html.indexOf(js);
2612 if (beg === -1)
2613 return html;
2614
2615 var val = js.substring(strFrom.length, js.length - strTo.length).trim();
2616 var compiled = exports.compile_javascript(val, filename, nomarkup);
2617 html = html.replacer(js, strFrom + compiled.trim() + strTo.trim());
2618 return compressJS(html, indexBeg + compiled.length + 9, filename, nomarkup);
2619}
2620
2621function compressCSS(html, index, filename, nomarkup) {
2622

Callers 2

internal.jsFile · 0.85
view_parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected