Installing mod_pagespeed for cPanel Apache installation on CentOS is really quite easy. Connect your server SSH via root user.
cd /usr/local/src
mkdir mod_pagespeed
cd mod_pagespeed
Download the mod_pagespeed RPM to build. Please make sure which arch is your server. If you have a 32-bit install of CentOS you can find your appropriate package on Google’s Installing mod_pagespeed From Packages page.
yum install at # if you do not already have ‘at’ installed
Mostly apache version 2.2 support for this mod pagespeed version (httpd >= 2.2 is needed by mod-pagespeed-stable-1.4.26.4-3396.x86_64)
Arrows are a function shorthand using the => syntax. They are syntactically similar to the related feature in C#, Java 8 and CoffeeScript. They support both statement block bodies as well as expression bodies which return the value of the expression. Unlike functions, arrows share the same lexical this as their surrounding code.
// Expression bodiesvar odds =evens.map(v=> v +1);
var nums =evens.map((v, i) => v + i);
var pairs =evens.map(v=> ({even: v, odd: v +1}));
// Statement bodiesnums.forEach(v=> {
if (v %5===0)
fives.push(v);
});
// Lexical thisvar bob = {
_name:"Bob",
_friends: [],
printFriends() {
this._friends.forEach(f=>console.log(this._name+" knows "+ f));
}
}
ES6 classes are a simple sugar over the prototype-based OO pattern. Having a single convenient declarative form makes class patterns easier to use, and encourages interoperability. Classes support prototype-based inheritance, super calls, instance and static methods and constructors.
Object literals are extended to support setting the prototype at construction, shorthand for foo: foo assignments, defining methods, making super calls, and computing property names with expressions. Together, these also bring object literals and class declarations closer together, and let object-based design benefit from some of the same conveniences.
Template strings provide syntactic sugar for constructing strings. This is similar to string interpolation features in Perl, Python and more. Optionally, a tag can be added to allow the string construction to be customized, avoiding injection attacks or constructing higher level data structures from string contents.
// Basic literal string creation`In JavaScript '\n' is a line-feed.`// Multiline strings`In JavaScript this is not legal.`// String interpolationvar name ="Bob", time ="today";
`Hello ${name}, how are you ${time}?`// Construct an HTTP request prefix is used to interpret the replacements and constructionPOST`http://foo.org/bar?a=${a}&b=${b} Content-Type: application/json X-Credentials: ${credentials} { "foo": ${foo}, "bar": ${bar}}`(myOnReadyStateChangeHandler);
Destructuring allows binding using pattern matching, with support for matching arrays and objects. Destructuring is fail-soft, similar to standard object lookup foo["bar"], producing undefined values when not found.
// list matchingvar [a, , b] = [1,2,3];
// object matchingvar { op: a, lhs: { op: b }, rhs: c }
=getASTNode()
// object matching shorthand// binds `op`, `lhs` and `rhs` in scopevar {op, lhs, rhs} =getASTNode()
// Can be used in parameter positionfunctiong({name: x}) {
console.log(x);
}
g({name:5})
// Fail-soft destructuringvar [a] = [];
a ===undefined;
// Fail-soft destructuring with defaultsvar [a =1] = [];
a ===1;
Callee-evaluated default parameter values. Turn an array into consecutive arguments in a function call. Bind trailing parameters to an array. Rest replaces the need for arguments and addresses common cases more directly.
functionf(x, y=12) {
// y is 12 if not passed (or passed as undefined)return x + y;
}
f(3) ==15
functionf(x, ...y) {
// y is an Arrayreturn x *y.length;
}
f(3, "hello", true) ==6
functionf(x, y, z) {
return x + y + z;
}
// Pass each elem of array as argumentf(...[1,2,3]) ==6
Iterator objects enable custom iteration like CLR IEnumerable or Java Iterable. Generalize for..in to custom iterator-based iteration with for..of. Don’t require realizing an array, enabling lazy design patterns like LINQ.
let fibonacci = {
[Symbol.iterator]() {
let pre =0, cur =1;
return {
next() {
[pre, cur] = [cur, pre + cur];
return { done:false, value: cur }
}
}
}
}
for (var n of fibonacci) {
// truncate the sequence at 1000if (n >1000)
break;
console.log(n);
}
Iteration is based on these duck-typed interfaces (using TypeScript type syntax for exposition only):
Generators simplify iterator-authoring using function* and yield. A function declared as function* returns a Generator instance. Generators are subtypes of iterators which include additional next and throw. These enable values to flow back into the generator, so yield is an expression form which returns a value (or throws).
Note: Can also be used to enable ‘await’-like async programming, see also ES7 await proposal.
var fibonacci = {
[Symbol.iterator]:function*() {
var pre =0, cur =1;
for (;;) {
var temp = pre;
pre = cur;
cur += temp;
yield cur;
}
}
}
for (var n of fibonacci) {
// truncate the sequence at 1000if (n >1000)
break;
console.log(n);
}
The generator interface is (using TypeScript type syntax for exposition only):
Non-breaking additions to support full Unicode, including new Unicode literal form in strings and new RegExp u mode to handle code points, as well as new APIs to process strings at the 21bit code points level. These additions support building global apps in JavaScript.
// same as ES5.1"ð ®·".length==2// new RegExp behaviour, opt-in ‘u’"ð ®·".match(/./u)[0].length==2// new form"\u{20BB7}"=="ð ®·"=="\uD842\uDFB7"// new String ops"ð ®·".codePointAt(0) ==0x20BB7// for-of iterates code pointsfor(var c of"ð ®·") {
console.log(c);
}
Language-level support for modules for component definition. Codifies patterns from popular JavaScript module loaders (AMD, CommonJS). Runtime behaviour defined by a host-defined default loader. Implicitly async model – no code executes until requested modules are available and processed.
// lib/math.jsexportfunctionsum(x, y) {
return x + y;
}
exportvar pi =3.141593;
Efficient data structures for common algorithms. WeakMaps provides leak-free object-key’d side tables.
// Setsvar s =newSet();
s.add("hello").add("goodbye").add("hello");
s.size===2;
s.has("hello") ===true;
// Mapsvar m =newMap();
m.set("hello", 42);
m.set(s, 34);
m.get(s) ==34;
// Weak Mapsvar wm =newWeakMap();
wm.set(s, { extra:42 });
wm.size===undefined// Weak Setsvar ws =newWeakSet();
ws.add({ data:42 });
// Because the added object has no other references, it will not be held in the set
Proxies enable creation of objects with the full range of behaviors available to host objects. Can be used for interception, object virtualization, logging/profiling, etc.
// Proxying a normal objectvar target = {};
var handler = {
get:function (receiver, name) {
return`Hello, ${name}!`;
}
};
var p =newProxy(target, handler);
p.world==='Hello, world!';
// Proxying a function objectvartarget=function () { return'I am the target'; };
var handler = {
apply:function (receiver, ...args) {
return'I am the proxy';
}
};
var p =newProxy(target, handler);
p() ==='I am the proxy';
There are traps available for all of the runtime-level meta-operations:
Symbols enable access control for object state. Symbols allow properties to be keyed by either string (as in ES5) orsymbol. Symbols are a new primitive type. Optional description parameter used in debugging - but is not part of identity. Symbols are unique (like gensym), but not private since they are exposed via reflection features likeObject.getOwnPropertySymbols.
Two new numeric literal forms are added for binary (b) and octal (o).
0b111110111===503// true0o767===503// true
Promises
Promises are a library for asynchronous programming. Promises are a first class representation of a value that may be made available in the future. Promises are used in many existing JavaScript libraries.
Full reflection API exposing the runtime-level meta-operations on objects. This is effectively the inverse of the Proxy API, and allows making calls corresponding to the same meta-operations as the proxy traps. Especially useful for implementing proxies.
Calls in tail-position are guaranteed to not grow the stack unboundedly. Makes recursive algorithms safe in the face of unbounded inputs.
functionfactorial(n, acc=1) {
'use strict';
if (n <=1) return acc;
returnfactorial(n -1, n * acc);
}
// Stack overflow in most implementations today,// but safe on arbitrary inputs in ES6factorial(100000)