Fix inline javascript comments breaking via compression layout

Also added a note into the README about this issue for developers
This commit is contained in:
Xevion
2022-09-22 01:26:24 -05:00
parent 2c599536f3
commit a15056e437
2 changed files with 11 additions and 5 deletions

View File

@@ -18,9 +18,16 @@ bundle exec jekyll serve --config _config.yml,_config_dev.yml
bundle exec jekyll build
```
## Development Notes
This site uses a special HTML compression layout. This can cause production-only issues as the compression is not used in development. Know the [restrictions][compression-layout-restrictions] of this layout. The primary issue to remember is below.
- Inline javascript (`<script>`) tags with single-line comments (`// Single-line comment`) can break, essentially cause all of the javascript to lay upon one line.
[user-url]: https://github.com/Xevion/
[repo-url]: https://github.com/Xevion/xevion.dev
[azabani-repo-url]: https://github.com/delan/www.azabani.com
[compression-layout-restrictions]: https://jch.penibelst.de/#restrictions
[website-url]: https://xevion.dev
[banner-url]: ./assets/img/index-cover.png
[license-url]: https://github.com/Xevion/xevion.dev/blob/master/LICENSE

View File

@@ -53,18 +53,17 @@ layout: compress
{% endif %}
</head>
<body class="{% if page.wide or layout.wide %}wide{% endif %}">
{{ content }}
</body>
<script type="text/javascript">
// Is all of this too much effort to make the animation play in just the right way?
/** Is all of this too much effort to make the animation play in just the right way? **/
window.onbeforeunload = function(){
// Remember the origin so it can be checked for page reloadss
/** Remember the origin so it can be checked for page reloads **/
sessionStorage.setItem("origin", window.location.href);
}
window.onload = function() {
// Display the glitch effect on new page loads or reloads.
/** Display the glitch effect on new page loads or reloads. **/
let glitch_seen = sessionStorage.getItem('glitch')
if (glitch_seen !== 'true' || window.location.href === sessionStorage.getItem("origin")) {
sessionStorage.setItem('glitch', 'true')