Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(docs-app): get rid of document.write for inserting scripts #15396

Closed
gkalpak opened this issue Nov 15, 2016 · 2 comments · Fixed by #17035
Closed

fix(docs-app): get rid of document.write for inserting scripts #15396

gkalpak opened this issue Nov 15, 2016 · 2 comments · Fixed by #17035

Comments

@gkalpak
Copy link
Member

gkalpak commented Nov 15, 2016

Since Chrome 54, scripts inserted via document.write generate a warning and might be blocked on slow networks (see this article for more info).

Since we are using document.write for scipts in our docs app, it might break on slow networks.

The warning message is:

A Parser-blocking, cross-origin script, https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-min.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.

@gkalpak gkalpak added this to the Backlog milestone Nov 15, 2016
gkalpak added a commit to gkalpak/angular.js that referenced this issue May 24, 2020
Previously, the docs app used `document.write()`, causing the following
warning on Chrome:

```
A parser-blocking, cross site (i.e. different eTLD+1) script,
https://ajax.googleapis.com/ajax/libs/angularjs/1.7.9/angular.min.js, is
invoked via document.write. The network request for this script MAY be
blocked by the browser in this or a future page load due to poor network
connectivity.
```

In the past, `document.write()` seems to have been used in order for
browsers (such as Firefox) to work correctly with our dynamically set
`<base>` tag and relative style/script URLs.

This commit replaces `document.write()` with regular
`<style>`/`<script>` tabs to avoid the warning (and potential issues due
to poor network connectivity). It seems that the latest versions of
Chrome, Firefox and IE can handle this fine (without naticeable delays).

Fixes angular#15396
petebacondarwin pushed a commit that referenced this issue May 25, 2020
Previously, the docs app used `document.write()`, causing the following
warning on Chrome:

```
A parser-blocking, cross site (i.e. different eTLD+1) script,
https://ajax.googleapis.com/ajax/libs/angularjs/1.7.9/angular.min.js, is
invoked via document.write. The network request for this script MAY be
blocked by the browser in this or a future page load due to poor network
connectivity.
```

In the past, `document.write()` seems to have been used in order for
browsers (such as Firefox) to work correctly with our dynamically set
`<base>` tag and relative style/script URLs.

This commit replaces `document.write()` with regular
`<style>`/`<script>` tabs to avoid the warning (and potential issues due
to poor network connectivity). It seems that the latest versions of
Chrome, Firefox and IE can handle this fine (without naticeable delays).

Fixes #15396
@Splaktar
Copy link
Member

Should this issue's milestone be updated to 1.8.x?

@petebacondarwin
Copy link
Member

Good spot @Splaktar !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants