Does PhantomJS support ES6 for serving angularjs app to crawlers and bots?
Asked Answered
A

1

7

I am trying to use ajax-seo for an Angularjs app to serve html compiled content from a PhantomJS webserver`. But it's not rendering the complete page. It's just giving the following response

<html><head></head><body></body></html>

I have followed the instructions well but no luck so far. So I'd like to know whether PhantomJS supports ES6 or not, because my app is in ES6.

Arsphenamine answered 4/6, 2016 at 11:40 Comment(4)
Which PhantomJS version do you use? Please register to the onConsoleMessage, onError, onResourceError, onResourceTimeout events (Example). Maybe there are errors.Notable
@ArtjomB. I am using phantomjs version 1.9.0. Am using the script from github.com/liuwenchao/ajax-seo/blob/master/seo.jsArsphenamine
@ArtjomB. Even after adding onConsoleMessage, onError and other methods specified by you, not getting any error. Simply getting the output as beforeArsphenamine
check out github.com/segmentio/nightmarePelagian
N
7

PhantomJS 2.1.1 only supports about 10% of ECMAScript 6, which might not be enough to properly render your page.

Here is a slightly more detailed result based on https://kangax.github.io/compat-table/es6/:

Overall coverage: 10%
> Array is subclassable: 0/11
> Array static methods: 0/11
> Array.prototype methods: 0/10
> Date.prototype[Symbol.toPrimitive]: No
> Function is subclassable: 0/6
> HTML-style comments: Yes
> Map: 0/19
> Math methods: 1/17
> Number properties: 0/7
> Object static methods: 0/4
> Object static methods accept primitives: 0/10
> Object.prototype.__proto__: 6/6
> Promise: 0/8
> Promise is subclassable: 0/4
> Proxy: 0/34
> Proxy, internal 'defineProperty' calls: 0/2
> Proxy, internal 'deleteProperty' calls: 0/6
> Proxy, internal 'get' calls: 0/36
> Proxy, internal 'getOwnPropertyDescriptor' calls: 0/4
> Proxy, internal 'ownKeys' calls: 0/3
> Proxy, internal 'set' calls: 0/11
> Reflect: 0/20
> RegExp "y" and "u" flags: 0/5
> RegExp is subclassable: 0/4
> RegExp syntax extensions: 8/8
> RegExp.prototype properties: 0/6
> RegExp.prototype.compile: Yes
> Set: 0/19
> String static methods: 0/2
> String.prototype HTML methods: 3/3
> String.prototype methods: 0/10
> Symbol: 0/11
> Unicode code point escapes: 0/2
> WeakMap: 0/12
> WeakSet: 0/11
> __proto__ in object literals: 1/5
> arrow functions: 0/13
> block-level function declaration: No
> class: 0/24
> const: 1/16
> default function parameters: 0/7
> destructuring, assignment: 0/24
> destructuring, declarations: 0/22
> destructuring, parameters: 0/23
> for..of loops: 0/9
> function "name" property: 3/17
> generators: 0/27
> let: 0/12
> miscellaneous: 2/10
> miscellaneous subclassables: 0/6
> new.target: 0/2
> non-strict function semantics: 2/3
> object literal extensions: 0/6
> octal and binary literals: 0/4
> own property order: 4/7
> proper tail calls (tail call optimisation): 0/2
> prototype of bound functions: 0/5
> rest parameters: 0/5
> spread (...) operator: 0/15
> super: 0/8
> template literals: 0/5
> typed arrays: 19/46
> well-known symbols: 0/26

This Gist contains the full data as well as the script that generated it.

Notable answered 4/6, 2016 at 14:24 Comment(4)
you mean to say I shouldn't use phantomjs as it won't render the complete web written in ES6?Arsphenamine
You could say that. You could also try to use a transpiler to convert your code base to ES5.Notable
Thankyou for your response. One more thing I want to know that what are the alternative to this? How can I make the ES6 based angularjs app SEO-friendly?Arsphenamine
"How can I make the ES6 based angularjs app SEO-friendly"... (facepalm) it's like asking how you can attach a wings to a car so that it can fly at least 200 m distance. Please be more precise. I also encounter issues with WeakMap in PhantomJS. But I assume it might be solved (as well as some other issues related to "reference error / not found") with some polyfill libs (like babel-polyfill) Maybe will be helpful to someone.Chlori

© 2022 - 2024 — McMap. All rights reserved.