├── .gitignore
├── static
├── favicon.ico
└── script.js
├── package.json
├── README.md
├── index.js
└── views
└── index.garnet
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stepchowfun/doesgoogleexecutejavascript/HEAD/static/favicon.ico
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "doesgoogleexecutejavascript",
3 | "version": "1.0.0",
4 | "description": "Yes.",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js"
8 | },
9 | "keywords": [
10 | "google",
11 | "javascript"
12 | ],
13 | "author": "Stephan Boyer",
14 | "license": "MIT",
15 | "dependencies": {
16 | "compression": "^1.6.0",
17 | "express": "^4.13.3",
18 | "garnet": "^0.1.9",
19 | "morgan": "^1.6.1"
20 | },
21 | "repository": {
22 | "type": "git",
23 | "url": "https://github.com/boyers/doesgoogleexecutejavascript.git"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/static/script.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', function() {
2 | document.getElementById('content').innerHTML =
3 | '
Yes,
' +
4 | '' +
5 | 'Google executes JavaScript, even if the script is fetched from ' +
6 | 'the network. However, Google does not make AJAX requests.' +
7 | '
';
8 |
9 | var xmlhttp = new XMLHttpRequest();
10 | xmlhttp.onreadystatechange = function() {
11 | if (xmlhttp.readyState === XMLHttpRequest.DONE && xmlhttp.status === 200) {
12 | document.getElementById('content').innerHTML = JSON.parse(xmlhttp.responseText).message;
13 | }
14 | };
15 | xmlhttp.open("GET", "/ajax", true);
16 | xmlhttp.send();
17 | }, false);
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Does Google Execute JavaScript?
2 |
3 | Google executes JavaScript, even if the script is fetched from the network. However, Google does not make AJAX requests.
4 |
5 | ## License
6 |
7 | Copyright (c) 2016 Stephan Boyer
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 |
13 | 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.
14 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////////////////////////////////////////
2 | // Configuration //
3 | //////////////////////////////////////////////////////////////////////////
4 |
5 | // express
6 | var express = require('express');
7 | var app = express();
8 |
9 | // request logging
10 | var morgan = require('morgan');
11 | app.use(morgan('short'));
12 |
13 | // compress responses
14 | var compression = require('compression');
15 | app.use(compression());
16 |
17 | // turn off unnecessary header
18 | app.disable('x-powered-by');
19 |
20 | // turn on strict routing
21 | app.enable('strict routing');
22 |
23 | // use the X-Forwarded-* headers
24 | app.enable('trust proxy');
25 |
26 | // template engine
27 | app.set('view engine', 'garnet');
28 |
29 | // other static files
30 | app.use(express.static('static'));
31 |
32 | //////////////////////////////////////////////////////////////////////////
33 | // Endpoints //
34 | //////////////////////////////////////////////////////////////////////////
35 |
36 | // landing page
37 | app.get('/', function(req, res) {
38 | res.render('index.garnet');
39 | });
40 |
41 | // ajax test
42 | app.get('/ajax', function(req, res) {
43 | res.json({
44 | message: 'Yes,
Google executes JavaScript and even makes AJAX requests.
',
45 | });
46 | });
47 |
48 | //////////////////////////////////////////////////////////////////////////
49 | // Main event loop //
50 | //////////////////////////////////////////////////////////////////////////
51 |
52 | // start the server
53 | var server = app.listen(process.env.PORT || 3000, function() {
54 | console.log('Listening on port %d.', server.address().port);
55 | });
56 |
--------------------------------------------------------------------------------
/views/index.garnet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Does Google Execute JavaScript?
7 |
14 |
15 |
16 |
25 |
54 |
55 |
56 |
57 |
No,
58 | Google does not execute JavaScript.
59 |
60 |
61 | This is an experiment to determine to what extent Google indexes dynamic content. The message above varies to indicate one of four possibilities:
62 |
63 |
64 | - The client does not execute JavaScript.
65 | - The client executes JavaScript, but only if it is embedded in the document.
66 | - The client executes JavaScript, even if the script is fetched from the network. However, the client does not make AJAX requests.
67 | - The client executes JavaScript and even makes AJAX requests.
68 |
69 | Google will index one of these messages—but which one? Click here to see the results of this experiment.
70 |
71 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------